This functional macro reads data from a visit connection.
Input Ports
Name Type Description SockID int Socket descriptor of the data-connection to the remote application. Trigger int Triggers reading of data from the data socket when activated. Output Ports
Name Type Description TimeStamp double Timestamp of the data read from the remote application. n1 int Size of field in dimension 1 n2 int Size of field in dimension 2 n3 int Size of field in dimension 3 n4 int Size of field in dimension 4 DataInt int[] Data field, if datatype of message is INT32. DataShort short[] Data field, if datatype of message is INT16. DataByte byte[] Data field, if datatype of message is BYTE. DataDouble double[] Data field, if datatype of message is FLOAT64. DataString string Data field, if datatype of message is STRING. DataIntScalar int Data value, if datatype of message is INT32 and the field length is 1. DataShortScalar short Data value, if datatype of message is INT16 and the field length is 1. DataByteScalar byte Data value, if datatype of message is BYTE and the field length is 1. DataDoubleScalar double Data value, if datatype of message is FLOAT64 and the field length is 1.
This module reads data from a remote application. The remote application it should connect to is specified by the SockID input. This input will normally be provided by the visitserver macro that has created the connection. The module is triggered whenever data arrives at the Trigger port. The Trigger input can be connected directly to the Trigger output port of a visitserver if only one visitreader or visitwriter macro is being used. If more than one visitreader or visitwriter is connected to a visitserver it is necessary to use a multiplexer macro in order to select a visitreader or visitwriter macro for each request. There is no implicit distinction between read and write requests. Therefore the user is responsible for using different IDs for read and write requests.
Whenever the module is triggered data is read from the remote application and presented on the output ports. The output ports TimeStamp and n1 ... n4 contain the header-information that has been sent by the remote application (using the
visit_send_4d
orvisit_send_string
function calls). The Data... output ports contain the data values that have been sent by the remote application. Depending on the type of data that has been sent the data will be presented on the appropriate Data output port. With a field of length n1=n2=n3=n4=1 the data is presented at both a vector and a scalar output port.The visitreader macro should be used in conjunction with the macros multiplexer, visitserver and visitwriter.
Before this module can be compiled and used the VISIT library must be installed. For information on how to install this library please see the VISIT library(http://www.fz-juelich.de/zam/visit) home page. A complete set of documentation for the VISIT-library can also be found at this URL.
The Visit IAC project assumes that the VISIT library has been installed into the default directory i.e.
/usr/local/visit/
If this is not the case then the references to that directory in the visit_mods.v file will have to be modified.
This functional macro is only provided for completeness. It is a very thin wrapper around the low-level VisitReader module. Therefore the VisitReader module should normally be used.
SockID
Integer input port that contains a socket descriptor. This socket descriptor specifies the data-connection to the remote application. This input port should be connected to the SockID output port of the visitserver macro.
Trigger
When this input is triggered the visitreader macro will attempt to read a message from the remote application. Normally this port should be connected to the Trigger output port of the visitserver macro. This should be done by either making a direct connection or making an indirect connection through a multiplexer macro.
Timestamp, n1, n2, n3, n4
Contain the header-information that has been sent by the remote application (using the visit_send_4d or visit_send_string function calls).
DataString
If the datatype of the read message is STRING this output port will present the data contained in the message.
DataInt, DataShort, DataByte, DataDouble
If the read message contains numerical data the values will be presented at one of these array outputs. The output used depends upon the datatype of the read message. If the message only contains a single value the value will also be presented at the appropriate scalar output.
DataIntScalar, DataShortScalar, DataByteScalar, DataDoubleScalar
If the read message contains a single numerical value the value will be presented at one of these scalar outputs. The output used depends upon the datatype of the read message. If the message contains more than one value these outputs will not used.
The User Macro visitreader is only a wrapper around the low-level module VisitReader. All input and output ports of this module are directly connected to the macro ports.
Two example applications are provided that work together with remote applications provided with the VISIT-library distribution. The VisitSimpleEg application is designed to test the installation of the Visit project and connects to the
vclient
remote application. If the project has been installed and compiled correctly several values should be sent to and received from the remote application. The test can be repeated several times by using the command line parameters of thevclient
application. For instance the following command will repeat the test 20 times:
vclient -p -n 20
The VisitGoLEg example application is a more complete visualization example that connects to a remote game of life simulation. The application connects to the
cgol
remote application. This application computes the game of life simulation for a 3D field and sends the full state of simulation to the AVS/Express application after every life step. As well as displaying the results of the simulation the VisitGoLEg application also allows the simulation to be steered. It is possible to insert new blocks into the simulation, and to stop or pause the remote application.A SEAP server must be running before either of these applications can be used. For full instructions on using the
cgol
andvclient
applications please see the VISIT library home page.
xp_comm_proj/visit/visit_macs.v contains the V definition of the functional macro visitreader.
The VisitMacs library inherits its process. As this library contains no procedural code, the process is not important. The modules in the low-level VisitMods library execute under the process specified in that library, not the process defined in the high-level library. By default the express process will be used.
Before the Visit project can be compiled the VISIT library must be installed, configured and compiled. For full instructions please see the VISIT library web-site.
The Visit IAC project assumes that the VISIT library has been installed into the default directory i.e.
/usr/local/visit/
If this is not the case then the references to that directory in the visit_mods.v file will have to be modified.
Wolfgang Frings Central Institute for Applied Mathematics Research Center Juelich D-52425 Juelich Germany
Ma YingLiang, Manchester Visualization Centre Andrew Dodd, International AVS Centre


This is a still image of the concept map for the term
"graph". You can check the actual concept map on the
glossary page.
Another name for "Directed graph" is ______
Look at these terms on the concept map.


--- layout: default ---
I love to develop websites from scratch, experiment with shiny new front end frameworks, take on just a bit more than I can handle, and code instead of studying for exams.
Explore and learn more about me! Where to first?


Metronome commit 9...
metronome updated 2018 10 21 22:43
play
Tempo:
120
BPM
Resolution:
16th notes
8th notes
4th notes
Load text
Zoe's fork on GitHub
Fork the original on GitHub
File contents:
...


Metro Icon Animation
Fancy animations for Metro UI.
Metro Icon Font gives you scalable vector icons that can instantly be customized — size, color, drop shadow, and anything that can be done with the power of CSS. Metro Icon Font includes over 400 icons.
How to use
Include in page head:
<link href="metro-icons.css" rel="stylesheet">
<link href="metro-ani-icons.css" rel="stylesheet">
In html use:

To change size icon you can use next classes: mif-lg, mif-2x, mif-3x, mif-4x.
Icons can be resized to any
sizes over built-in classes

To change icon color you can use fg-* classes or use css property color.

Icons
Below is an example of animations that you can now use.
Spinner icons
- spinner
- spinner2
- spinner3
- spinner4
- spinner5
- loop2
Animated Spinner icons (with subclass mif-ani-spin)
- spinner
- spinner2
- spinner3
- spinner4
- spinner5
- loop2
Animated Spinner icons (with subclass mif-ani-pulse)
- spinner
- spinner2
- spinner3
- spinner4
- spinner5
- loop2
Animated Spinner icons (with subclass mif-ani-pulse2) New
- spinner
- spinner2
- spinner3
- spinner4
- spinner5
- loop2
Animated icons New
Normal speed
- spanner
- bell
- vertical
- horizontal
- flash
- bounce
- float
- heartbeat
- shake
- shuttle
- pass
- ripple
Fast speed (with subclass mif-ani-fast)
- spanner
- bell
- vertical
- horizontal
- flash
- bounce
- float
- heartbeat
- shake
- shuttle
- pass
- ripple
Slow speed (with subclass mif-ani-slow)
- spanner
- bell
- vertical
- horizontal
- flash
- bounce
- float
- heartbeat
- shake
- shuttle
- pass
- ripple
On hover
- spanner
- bell
- vertical
- horizontal
- flash
- bounce
- float
- heartbeat
- shake
- shuttle
- pass
- ripple


Landing Page
Special Projects
This story is part of a series of specially designed stories that represents some of the best journalism The Post has to offer. Check out the rest of the special projects here.
MEAGAN HALL
09.07.17
The start of Duane Nellis’ presidency in June came alongside the end of university-provided housing for Ohio University’s presidents amid a state investigation into the matter.
Nellis and his wife, Ruthie, live about 2 miles south of OU’s Athens campus at 36 Warren Road in a home they purchased for $650,000 in late May. Per his contract, the university provides Nellis a $5,000 monthly housing allowance and requires that he live in Athens County.
PROVIDED VIA Google Maps
A satellite view of 36 Warren Road.
OU’s Board of Trustees decided to use a monthly stipend rather than “offer the benefit of a house with an unknown cost” before Nellis was hired, OU Spokeswoman Carly Leatherwood said.
The housing allowance is a shift from the university’s previous policies toward housing its presidents. Until two years ago, presidents had lived near the center of campus at 29 Park Place since 1952, according to OU’s website.
In 2015, OU decided to move former OU President Roderick McDavis and his wife, Deborah, from 29 Park Place to an off-campus house at 31 Coventry Lane through a $1.2 million lease-purchase agreement.
The university later announced it would only lease the home due to a •“problematic” verbal agreement its owner made with OU Director of Athletics Jim Schaus, according to a previous Post report.
The lease for that house ended June 30, Leatherwood said. But OU is still being investigated by the Ohio Office of the Inspector General for matters related to presidential housing as part of an investigation that started in 2015, according to another Post report.
Nellis’ house purchase in May included three parcels of land of 9 total acres, according to the Athens County auditor’s website. Additionally, his contract states that the house may be used for “university-related business and entertainment” and states that the university will cover the costs of such events.
“The terms of Dr. Nellis’ contract, including the housing allowance, reflect national trends in higher education executive compensation,” Board of Trustees Chair Janetta King said in an email. “President Nellis’ compensation affirms the high degree of confidence the Board has in him to lead the institution into its third century.”
Research shows, however, that allowances are less common nationally, according to a study conducted by James Finkelstein and Judith Wilde of George Mason University that analyzed presidential contracts at 115 public universities.
“The two most traditional perks historically are a car and housing,” Finkelstein, professor emeritus of public policy at George Mason, said regarding university presidents. “We’ve looked at all kinds of perks. Those have been around for decades.”
About 72 percent of the institutions studied required university-provided housing for presidents, and only 17 percent of them specifically listed a housing allowance for presidents to live off campus, said Wilde, chief operating officer of the university’s Schar School of Policy and Government.
OU’s housing allowance of $60,000 a year is above average, Finkelstein said. The housing allowances the two studied varied from $18,000 to $72,000 with an average of about $42,500.
“I’ve been at a couple universities when that shift was made,” Wilde said of moving to off-campus presidential housing. “In those cases, it was due to other family matters … or it was because the on-campus housing had gotten old enough that it needed major renovations.”
Landing Page
This story is part of a series of specially designed stories that represents some of the best journalism The Post has to offer. Check out the rest of the special projects here.


6.4
domestic | energy | insulation of pipes, ducts and vessels | 2010
Every
building
must be designed and
constructed
in such a way that
temperature loss from heated pipes,
ducts
and vessels, and
temperature gain to cooled pipes and
ducts
, is resisted.
Limitation:
This standard does not apply to:
(a)
buildings
which do not use fuel or power for heating or cooling
either the internal environment or water services;
(b)
than heating provided solely for the purpose of frost protection; or
(c)
pipes,
ducts
or vessels that form part of an isolated industrial or
commercial process.
6.4.0 Introduction
Thermal insulation to heating pipes and
ducts
and hot water storage vessels
will improve energy efficiency by preventing:
•
uncontrolled heat loss from such equipment; and
•
an uncontrolled rise in the temperature of the parts of the
building
where
such equipment is situated.
In the case of conversions, as specified in regulation 4, the
building
as
converted
shall meet the requirements of this standard in so far as is
reasonably practicable
, and in no case be worse than before the conversion
(regulation 12, schedule 6).
6.4
—
6.4.0
domestic | energy | insulation of pipes, ducts and vessels | 2010
6.4.1 Insulation of pipes and
ducts
Warm air
ducts
and hot water pipes serving a space heating system should
be thermally insulated against uncontrolled heat loss unless the use of such
space. In some cases this will not be necessary where pipe and
duct
runs
occur just behind the internal wall or ceiling linings of the
insulation envelope.
This will not only address energy conservation issues but will also assist with
frost protection. Further information on this subject is contained in BR 262,
Hot water pipes to
appliances
Pipes that are used to supply hot water to appliances within a
domestic
building
should be insulated against heat loss. This is to conserve heat in the
hot water pipes between frequent successive draw-offs. All pipes of a solar
water heating primary system should be insulated.
Insulation for such pipes and
ducts
may be provided by following the
guidance on insulation thickness given in BS 5422: 2009. The selection of
insulation thickness should be representative of both environmental
conditions and fluid temperatures within the pipe or
duct
in question. For
example, reference can be made to the 2001 edition of BS 5422 for
insulation to pipework within unheated areas.
The
building
design should be considered at an early stage to ensure
complete insulation of pipes and
ducts
, where such services pass through or
around structural
building
components.
6.4.2 Insulation of vessels
A hot water storage vessel should be insulated against heat loss. Vented
copper hot water storage cylinders should comply with the heat loss
recommendations within BS 1566-1: 2002. Vessels themselves should be
identified as having a standing heat loss (kWh/day) of not more than 1.15 x
(0.2 + 0.051 V²/³) where V is the declared volume of the vessel.
In addition to guidance within clause 6.4.1, other pipework that connects to
the vessel, including any vent pipe or primary flow and return should also be
insulated from their point of connection to the vessel to a distance of
about 1 m or to where they pass into the
building
fabric.
Insulation should not compromise the safe operation of the system and of
any safety devices fitted including, on unvented cylinders, the visibility of
warning discharges.
Where a new or replacement boiler or hot water storage vessel is installed, or
where existing systems are extended, new or existing pipes that are
accessible or exposed as part of the
work
should be insulated as for new
systems. Replacement hot water storage vessels should be insulated as for a
new vessel and should be identified as having a standing heat loss
(kWh/day) of not more than 1.28 x (0.2 + 0.051 V²/³), where V is the declared
volume of the vessel.
It is recognised that complete insulation will sometimes not be possible,
where such services pass through or around structural
building
components,
floor joists, for example or where existing systems are wholly or partially
retained as part of
conversion works
. In such cases, insulation should be
fitted as for new systems as far as is
reasonably practicable.
6.4.1
—
6.4.3


These tests all explore what happens if multiple changes happen in quick succession, such as two live region changes, or live region changes and focus changes.


The American’s postseason meet is on Saturday at Belmont Plateau. Here are the top 6,000-meter times for women and 8,000-meter times for the men of each team in the conference.
*Central Florida and South Florida didn’t run 6,000s this season. Kalleigh Forrester and Ramia Samhouri’s times are calculated based off their 5,000-meter results.

JULIE CHRISTIE, GRETA ANDERSON / THE TEMPLE NEWS


Preparation time
over 2 hours
Cooking time
no cooking required
Serves
Serves 4
Dietary
A new dish is always an exciting and rewarding moment for any cook, but there is a lot of trial and error to get it just right. After countless re-working, I think this recipe is the perfect iced tart. It’s a little bit demanding but worth the challenge – both in terms of appearance and flavour.
Equipment and preparation: for this recipe you will need: 4 x 7.5cm/3in pastry rings and 4 x 6cm/2½in pastry rings; a 25x5cm/10x2in piece of acetate to line the insides of the frame; and a squeezy plastic bottle.
Take four 7.5cm/3in pastry rings and tightly stretch cling film over the top of each one, then turn them upside down; these will become the frames for the tarts. Line a tray with greaseproof paper, place the pastry rings on the tray with the cling film on the bottom, line the insides with the acetate plastic and transfer to the freezer.
For the sorbet, in a large bowl macerate the strawberries with the stevia and lemon juice for 30 minutes. Macerating the strawberries will give the sorbet much more flavour.
Blend the strawberries to a purée. Set aside 150g/5oz of the purée and pour the remainder into a squeezy plastic bottle. Squeeze the purée into the bottom of each frozen pastry ring until you have 5mm layer covering the bottom. Return the tray to the freezer and freeze for 30 minutes, or until frozen solid.
Remove from the freezer and place a 6cm/2½in pastry ring centrally on top of each circle of frozen purée. Gently press it down so that it just indents the base. Squeeze more purée into the gap between the two rings, to create a wall 2cm/¾in high.
Place back in the freezer and leave to freeze for at least 2 hours, or until solid. (The steps up to this stage can be done a few days in advance.) Place 4 serving plates in the freezer 1 hour prior to serving.
For the tart filling, in a bowl macerate the strawberries with the stevia for 30 minutes.
Meanwhile, make the crème Chantilly by whipping the cream with the stevia and vanilla purée or extract, until firm peaks form when the whisk is removed. (Beware, if you over-whip the cream, it will separate and you will create butter!)
Mix 100g/3½oz of the reserved purée with the macerated strawberries. Fold half the macerated strawberries through the Chantilly cream. Reserve the other half for decorating.
Take one sorbet out of the freezer. Remove the inner pastry ring by rubbing your fingers around the inside to soften the sorbet behind it slightly and enable you to gently lift off the ring. Now lift off the outer pastry ring and gently peel away the acetate surrounding the sorbet. Return each sorbet case to a baking tray in the freezer as you repeat this process for the remaining sorbets.
When ready to serve, remove the plates from the freezer and place a small amount of the crushed meringue in the centre of each plate to stop the tarts from sliding around, then cover with a frozen sorbet case.
Place a spoonful of the jam in the bottom of each sorbet case, followed by the strawberry and Chantilly cream mix. Finish each tart with a spoonful of the reserved macerated strawberries, followed by a few whole meringues and mint leaves. Drizzle the remaining reserved purée around each tart, place a few halved strawberries on the plates and serve immediately.


Links
I find a wide variety of things interesting and/or useful on the web. These are just some of them.
--- layout: links ---
I find a wide variety of things interesting and/or useful on the web. These are just some of them.
|
site |
what is it |
|
Website for Code repositories |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Robust workflow with StatET + Eclipse (+ SVN + LaTeX + Sweave + BibTeX + Zotero) |
|
|
An excellent resource for programmers both beginner and experienced. Be sure to check out other related subreddits from their sidebar. |
|
For choosing palettes for graphs that are distinct or that have desired properties |
|
|
|
|
|
|
|
|
Think Yahoo! Answers but more…serious. You can find some discussions on very interesting questions. You do need to sign up though. |
|
|
|
|
|
microsoft-fonts |
|


Kelsey James
About
(current)
Portfolio
(current)
Contact
(current)
Previous
Next
Weather Dashboard
Dayplanner Website
Previous
Next
Earthquake Tracker
Quiz App


Financial Aid
Daunted by dollar signs? Don’t be. The Office of Financial Assistance is your go-to place for understanding how to pay for college and make the best of your investment. Our team will help you search for scholarships, apply for financial aid, find student jobs and make smart decisions about loans. We can even help you budget for the fun stuff, like spring break and a semester abroad.
No matter who you are, you've got to reapply for aid each year. Need some help? Come by our offce! Financial aid counseling is available on a walk-in basis. To protect your privacy, we offer limited counseling services through phone and email.
There's more to financial aid than scholarships and loans! We also have positions available in athletics, recreation, classrooms, laboratories, the Library, offices, research, information services, and many other areas through our Federal Work Study program.
If you need financial aid and you qualify—75 percent of all UCF students do—the combination of financial aid plus scholarship funds can have a profound impact on your future success in and after college. Whether you're interested in learning about scholarships, loans, personal finance, or you just want to find out how to renew your financial support, we've got the information you need.
Additional Services
APPLYING FOR AID
All students must apply yearly for financial aid. To be given the greatest consideration, students should complete the Free Application for Federal Student Aid (FAFSA) prior to March 1st, the UCF priority date.
SCHOLARSHIPS
Scholarships are designed to reward, encourage and assist you in pursuing academic excellence and leadership roles. Many colleges and departments offfer scholarships to students that are specific to an area of specialization.
LOANS
UCF participates in the Federal Direct Loan Program. Direct Loans are low-interest educational loans administered through the U.S. Department of Education, which consists of the Federal Stafford, PLUS, and Grad PLUS Loans.
STUDENT EMPLOYMENT
The Federal Work Study provides part-time jobs for students on and off-campus. We can help you find a job that fits your schedule and is just minutes from your classes!


{% extends "app/layout.html" %} {% load staticfiles %} {% load bootstrap_components %} {% block content %}
No instream flow rights have been entered for this scenario yet.
{% endif %}No agricultural data has been entered for this scenario yet.
{% endif %}


Scan Results
Potential Phishing Attempts
Some text..
Click here for detailed analysis
SSL/TLS Certificate Validation
Some text..
Open Redirects
Some text..
Cross-Site Scripting (XSS)
Some text..
×
Phishing Detection Parameters
Paramter
Description
Status
Parameter1
Proceed to url


IPRES is a simple HTML wrapper / presentation editor (https://github.com/zglu/ipres).
This page is designed for slides using Shower.
Edit
© 2017 ipres.xyz - 🔝
IPRES is a simple HTML wrapper / presentation editor (https://github.com/zglu/ipres).
This page is designed for slides using Shower.
© 2017 ipres.xyz - 🔝


Swamp Rabbit Cycling
Bringing you the best in bicyclce gear, equipment and comunity since 1999!
Previous
Next
From mountain bikes to kids training wheels, we've got what you need. come join use for our Saturday community events or just stop by to say hello!
Visit, call or email us today and get the most out of your bike riding experience!
(202) 555-0127
swamprabbitcycling@example.com


//If the value is entered ‘123’, alert should be ‘One Two Three’
var a=prompt("Please enter your number");
var Exam =function (num){
if(num == "123"){
alert("One Two Three");
}
if(num == "124"){
alert("One Two Four");
}
if(num == "125"){
alert("One Two Five");
}
if(num == "126"){
alert("One Two Five");
}
}
Exam(a);


Seattle Washington...the town by the sea. They are known for their fresh seafood and their amazing coffee. Our founder Pat wanted to share his love for the best things of Seattle. He found a way to combine the sweet goodness of cookies with the rich flavor of salmon into one-bite easy-to-eat snack. Over 15 years he perfected a recipe and now he is ready to share this fleshy goodness with the world. Come to one of our international locations and try a fishy treat.


Testing Controllers
Testing your controllers is made convenient with a couple of new helper classes and traits. When testing controllers, you can execute the code within a controller, without first running through the entire application bootstrap process. Often times, using the Feature Testing tools will be simpler, but this functionality is here in case you need it.
Note
Because the entire framework has not been bootstrapped, there will be times when you cannot test a controller this way.
The Helper Trait
To enable Controller Testing you need to use the ControllerTestTrait
trait within your tests:
<?php
namespace CodeIgniter;
use CodeIgniter\Test\CIUnitTestCase;
use CodeIgniter\Test\ControllerTestTrait;
use CodeIgniter\Test\DatabaseTestTrait;
class TestControllerA extends CIUnitTestCase
{
use ControllerTestTrait;
use DatabaseTestTrait;
}
Once the trait has been included, you can start setting up the environment, including the request and response classes,
the request body, URI, and more. You specify the controller to use with the controller()
method, passing in the
fully qualified class name of your controller. Finally, call the execute()
method with the name of the method
to run as the parameter:
<?php
namespace CodeIgniter;
use CodeIgniter\Test\CIUnitTestCase;
use CodeIgniter\Test\ControllerTestTrait;
use CodeIgniter\Test\DatabaseTestTrait;
class TestControllerA extends CIUnitTestCase
{
use ControllerTestTrait;
use DatabaseTestTrait;
public function testShowCategories()
{
$result = $this->withURI('http://example.com/categories')
->controller(\App\Controllers\ForumController::class)
->execute('showCategories');
$this->assertTrue($result->isOK());
}
}
Helper Methods
controller($class)
Specifies the class name of the controller to test. The first parameter must be a fully qualified class name (i.e., include the namespace):
<?php
$this->controller(\App\Controllers\ForumController::class);
execute(string $method, …$params)
Executes the specified method within the controller. The first parameter is the name of the method to run:
<?php
$results = $this->controller(\App\Controllers\ForumController::class)
->execute('showCategories');
By specifying the second and subsequent parameters, you can pass them to the controller method.
This returns a new helper class that provides a number of routines for checking the response itself. See below for details.
withConfig($config)
Allows you to pass in a modified version of app/Config/App.php to test with different settings:
<?php
$config = new \Config\App();
$config->appTimezone = 'America/Chicago';
$results = $this->withConfig($config)
->controller(\App\Controllers\ForumController::class)
->execute('showCategories');
If you do not provide one, the application’s App config file will be used.
withRequest($request)
Allows you to provide an IncomingRequest instance tailored to your testing needs:
<?php
$request = new \CodeIgniter\HTTP\IncomingRequest(
new \Config\App(),
new \CodeIgniter\HTTP\URI('http://example.com'),
null,
new \CodeIgniter\HTTP\UserAgent()
);
$request->setLocale($locale);
$results = $this->withRequest($request)
->controller(\App\Controllers\ForumController::class)
->execute('showCategories');
If you do not provide one, a new IncomingRequest instance with the default application values will be passed into your controller.
withResponse($response)
Allows you to provide a Response instance:
<?php
$response = new \CodeIgniter\HTTP\Response(new \Config\App());
$results = $this->withResponse($response)
->controller(\App\Controllers\ForumController::class)
->execute('showCategories');
If you do not provide one, a new Response instance with the default application values will be passed into your controller.
withLogger($logger)
Allows you to provide a Logger instance:
<?php
$logger = new \CodeIgniter\Log\Handlers\FileHandler();
$results = $this->withResponse($response)
->withLogger($logger)
->controller(\App\Controllers\ForumController::class)
->execute('showCategories');
If you do not provide one, a new Logger instance with the default configuration values will be passed into your controller.
withURI(string $uri)
Allows you to provide a new URI that simulates the URL the client was visiting when this controller was run. This is helpful if you need to check URI segments within your controller. The only parameter is a string representing a valid URI:
<?php
$results = $this->withURI('http://example.com/forums/categories')
->controller(\App\Controllers\ForumController::class)
->execute('showCategories');
It is a good practice to always provide the URI during testing to avoid surprises.
Note
Since v4.4.0, this method creates a new Request instance with the URI.
Because the Request instance should have the URI instance. Also if the hostname
in the URI string is invalid with Config\App
, the valid hostname will be
set.
withBody($body)
Allows you to provide a custom body for the request. This can be helpful when testing API controllers where you need to set a JSON value as the body. The only parameter is a string that represents the body of the request:
<?php
$body = json_encode(['foo' => 'bar']);
$results = $this->withBody($body)
->controller(\App\Controllers\ForumController::class)
->execute('showCategories');
Checking the Response
ControllerTestTrait::execute()
returns an instance of a TestResponse
. See Testing Responses on
how to use this class to perform additional assertions and verification in your test cases.
Filter Testing
Similar to Controller Testing, the framework provides tools to help with creating tests for custom Filters and your projects use of them in routing.
The Helper Trait
Just like with the Controller Tester you need to include the FilterTestTrait
in your test
cases to enable these features:
<?php
namespace CodeIgniter;
use CodeIgniter\Test\CIUnitTestCase;
use CodeIgniter\Test\FilterTestTrait;
class FilterTestCase extends CIUnitTestCase
{
use FilterTestTrait;
}
Configuration
Because of the logical overlap with Controller Testing FilterTestTrait
is designed to
work together with ControllerTestTrait
should you need both on the same class.
Once the trait has been included CIUnitTestCase
will detect its setUp
method and
prepare all the components needed for your tests. Should you need a special configuration
you can alter any of the properties before calling the support methods:
$request
A prepared version of the defaultIncomingRequest
service$response
A prepared version of the defaultResponseInterface
service$filtersConfig
The defaultConfig\Filters
configuration (note: discovery is handle byFilters
so this will not include module aliases)$filters
An instance ofCodeIgniter\Filters\Filters
using the three components above$collection
A prepared version ofRouteCollection
which includes the discovery ofConfig\Routes
The default configuration will usually be best for your testing since it most closely emulates a “live” project, but (for example) if you wanted to simulate a filter triggering accidentally on an unfiltered route you could add it to the Config:
<?php
namespace CodeIgniter;
use CodeIgniter\Test\CIUnitTestCase;
use CodeIgniter\Test\FilterTestTrait;
final class FilterTestCase extends CIUnitTestCase
{
use FilterTestTrait;
protected function testFilterFailsOnAdminRoute()
{
$this->filtersConfig->globals['before'] = ['admin-only-filter'];
$this->assertHasFilters('unfiltered/route', 'before');
}
// ...
}
Checking Routes
The first helper method is getFiltersForRoute()
which will simulate the provided route
and return a list of all Filters (by their alias) that would have run for the given position
(“before” or “after”), without actually executing any controller or routing code. This has
a large performance advantage over Controller and HTTP Testing.
- getFiltersForRoute($route, $position)
- Parameters
$route (
string
) – The URI to check$position (
string
) – The filter method to check, “before” or “after”
- Returns
Aliases for each filter that would have run
- Return type
string[]
Usage example:
<?php $result = $this->getFiltersForRoute('/', 'after'); // ['toolbar']
Calling Filter Methods
The properties describe in Configuration are all set up to ensure maximum performance without interfering or interference from other tests. The next helper method will return a callable method using these properties to test your Filter code safely and check the results.
- getFilterCaller($filter, $position)
- Parameters
$filter (
FilterInterface|string
) – The filter instance, class, or alias$position (
string
) – The filter method to run, “before” or “after”
- Returns
A callable method to run the simulated Filter event
- Return type
Closure
Usage example:
<?php namespace CodeIgniter; use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\FilterTestTrait; final class FilterTestCase extends CIUnitTestCase { use FilterTestTrait; protected function testUnauthorizedAccessRedirects() { $caller = $this->getFilterCaller('permission', 'before'); $result = $caller('MayEditWidgets'); $this->assertInstanceOf('CodeIgniter\HTTP\RedirectResponse', $result); } }
Notice how the
Closure
can take input parameters which are passed to your filter method.
Assertions
In addition to the helper methods above FilterTestTrait
also comes with some assertions
to streamline your test methods.
assertFilter()
The assertFilter()
method checks that the given route at position uses the filter (by its alias):
<?php
// Make sure users are logged in before checking their account
$this->assertFilter('users/account', 'before', 'login');
assertNotFilter()
The assertNotFilter()
method checks that the given route at position does not use the filter (by its alias):
<?php
// Make sure API calls do not try to use the Debug Toolbar
$this->assertNotFilter('api/v1/widgets', 'after', 'toolbar');
assertHasFilters()
The assertHasFilters()
method checks that the given route at position has at least one filter set:
<?php
// Make sure that filters are enabled
$this->assertHasFilters('filtered/route', 'after');
assertNotHasFilters()
The assertNotHasFilters()
method checks that the given route at position has no filters set:
<?php
// Make sure no filters run for our static pages
$this->assertNotHasFilters('about/contact', 'before');


The intro part of the index page (Header) is consisted of four elements:
The black favicon is an image on the left of the navigation bar. Preferably it should be a black and white version of your favicon.
black-favicon: "/img/black-lab-glass.ico"
In order to set the background, set the path to following variable:
background-img: "../img/intro-bg.jpg"
NB! Keep the .. in the beginning of the background image path
The welcome text is controlled by the following (self-explanatory) variables:
dynamic-typing: True
shuffle: True # Shuffle the lines.
loop: True
loop-count: False # Set False for infinite loop, or set any number for finite loop.
type-speed: 10 # Default 10
start-delay: 200 # Default 200
delete-delay: 5000 # Default 5000
lines: # You can add HTML Tags in the Text
- text: "The lower you fall, the higher you'll fly."
- text: "Where’s your will to be weird?"
Many thanks to @prashantsolanki3 for the dynamic typing feature!
You can set your image from the following variable:
me-img: "/img/jetpacktocat.png"
If you want to connect your Facebook profile image then you can use the following.
Replace user_id
with your facebook user id. Facebook user id can be found by clicking
on your profile pic and the large number in the end of the url just before ‘&type’ is your user id.
Note: fbid is not the same as user id and user id only contains numbers.
me-img: "https://graph.facebook.com/user_id/picture?type=large&width=500&height=500"
If you want to connect your Github profile image then you can use the following.
Replace user_name
with your Github user name.
me-img: "https://github.com/user_name.png?size=500"
If you want to connect your Gravatar profile image then you can use the following.
Replace email_hash
with your Gravatar profile email hash.
You can create the email hash by using an online tool like md5hashgenerator,
just enter your email and it will generate the hash.
me-img: "https://www.gravatar.com/avatar/email_hash?s=500"
All set!


Testcases for Site Map Extractor
Last tested with:
- Burp Suite Pro 2.1.07
- Jython 2.7.1
How to test?
Put this file on a webserver and request it (make sure you get a 200, not cache) using a browser with Burp as proxy.
Open the Site Map Extractor Extension, set it to full site map and hit 'run'.
Re-test? Delete the request 'item' from the Proxy > HTTP History first.
== http cases with double quotes ===
Case 1A: " with http
1A
Case 1B: " with http and target blank
1B
Case 1C: " with http and target _blank with rel="nofollow"
1C
Case 1D: " with http and target _blank with rel="nofollow noreferrer"
1D
Case 1E: " with http and target _blank with rel="nofollow noreferrer"
1E
== https cases with double quotes ===
Case 2A: " with https
2A
Case 2B: " with https and target blank
2B
Case 2C: " with https and target _blank with rel="nofollow"
2C
Case 2D: " with https and target _blank with rel="nofollow noreferrer"
2D
Case 2E: " with https and target _blank with rel="nofollow noreferrer noopener"
2E
== https cases with double quotes to other domain===
Case 3A: " with https to other domain
3A
Case 3B: " with https and target blank to other domain
3B
Case 3C: " with https and target _blank with rel="nofollow" to other domain
3C
Case 3D: " with https and target _blank with rel="nofollow noreferrer" to other domain
3D
== http cases with single quotes ===
Case 4A: ' with http
4A
Case 4B: ' with http and target blank
4B
Case 4C: ' with http and target _blank with rel='nofollow'
4C
Case 4D: ' with http and target _blank with rel='nofollow noreferrer'
4D
== https cases with double quotes ===
Case 5A: ' with https
5A
Case 5B: ' with https and target blank
5B
Case 5C: ' with https and target _blank with rel='nofollow'
5C
Case 5D: ' with https and target _blank with rel='nofollow noreferrer'
5D
== https cases with double quotes to other domain===
Case 6A: ' with https to other domain
6A
Case 6B: ' with https and target blank to other domain
6B
Case 6C: ' with https and target _blank with rel='nofollow' to other domain
6C
Case 6D: ' with https and target _blank with rel='nofollow noreferrer' to other domain
6D
== relative cases with single quotes ===
Case 7A: ' with relative
7A
Case 7B: ' with http and target blank
7B
Case 7C: ' with http and target _blank with rel='nofollow'
7C
Case 7D: ' with http and target _blank with rel='nofollow noreferrer'
7D
== relative cases with double quotes ===
Case 8A: ' with relative
8A
Case 8B: ' with https and target blank
8B
Case 8C: ' with https and target _blank with rel='nofollow'
8C
Case 8D: ' with https and target _blank with rel='nofollow noreferrer'
8D
== Some troublemakers ;)
10A
10B
10C
10D
10E
10F
10G
10H
10I
10J: Exact case yet unknown, but happens sometimes with unicode, add when known


Skyscrapers tower above the City and Docklands like vast monuments to finance.
Shoppers teem around Oxford Street and Piccadilly. Georgian terraces and inter-war suburbs alike are not just homes but also prime real estate.
And with wealth comes power. London is a global city whose dominant status both within the UK and the rest of the world is unquestionable.
For some British people, all this is a cause for pride and celebration. For others it's a source of resentment and unease.
How did it get to this position?
London's stature is remarkable. Can anywhere else claim to be both an international focal point of such significance and so commanding a national capital?
Just before this year's UK General Election, listeners of US National Public Radio were told that it “completely dominates the political, cultural and economic life of the UK to an extent rarely seen elsewhere”.
New York might rival it as an economic hub – though London recently overtook its US rival in the Global Financial Centres Index (GFCI) rankings. But New York isn't at the same time the seat of political power in the US or home to the nation's central bureaucracy.
Paris dominates France, but lags behind its British counterpart in terms of international finance, sitting at 37th in the GFCI table.
No-one doubts London's pervasive economic influence. More than a third of global foreign exchange takes place every day in London.
The city is home to 251 overseas banks. UK financial services had a trade surplus of $71bn in 2013. London's GDP is equal to that of Saudi Arabia.
And in relation to the rest of the UK, London's dominance is especially striking.
The capital generates 22% of UK GDP despite accounting for only 12.5% of the UK population. According to the Centre for Economic and Business Research, it makes a net contribution to the Exchequer of an astonishing £34bn.
Inner London's GDP per head was 328% of the European Union average in 2010, compared with 70% in west Wales - the biggest gap in any EU state, said the European Commission's statistics agency Eurostat. Among the next eight largest UK cities, only one other, Bristol, has a GDP that is above the national average.
In 2013 it was estimated that in property terms London's top 10 boroughs were worth more than all of Northern Ireland, Scotland and Wales combined. London's housing stock is worth as much as Brazil's annual GDP, estate agents Savills reported in January 2015.
A cul-de-sac comprising a score of 1930s semi-detached homes in Ilford or Hounslow might easily be worth £10m.
Not that all Londoners are enjoying this prosperity.
A 2013 report by the New Policy Institute suggested that 28% of people in London were in poverty, seven percentage points higher than the remainder of England. Two of the city's boroughs are among England's top 10 most deprived. If the capital is a place where wealth is concentrated it is also one where inequality is highly visible and inescapable.
But just as London's wealth is not shared by all who live there, the city's dominance is not just about economic performance. The UK's parliament is in London. So too is Whitehall's central government machinery - London had 76,840 civil servants in 2014.
The default position is that major businesses and institutions, from Shell to the British Museum - not to mention the BBC - are headquartered in the capital as a matter of course.
London is Europe's fastest-growing technology cluster, with 3,000 companies concentrated in the East End. The British film industry is synonymous with the names of places in and around London - Ealing, Pinewood, Shepperton. The city is a major international centre for fashion, art and theatre, too.
“It's where all the rich people are,” says John Lanchester, author of Capital and How to Speak Money. “It's where all the media is, all the power is, all the culture is, all the money is - that is a lot of alls. Around the country people look at London and they don't really recognise themselves.”
Compare this with Germany, where the political capital Berlin is balanced by a financial hub in Frankfurt and powerful industrial and media centres in Munich and Hamburg. New York's global status doesn't diminish Washington's political clout, Los Angeles' entertainment output or San Francisco's position at the vanguard of the technology industry.
Taking into account population size relative to the rest of the country, only Moscow among major global capitals accounts for a greater share of national product, wrote Danny Dorling, professor of geography at the University of Oxford. Even Paris takes a lower share of French GDP.
And despite devolution, and the efforts of organisations like the BBC and the civil service to shift jobs into the regions, London enjoys a status within the UK that no other British city can compete with, and a reputation for being a worldwide cultural centre - particularly in relation to youth culture.
And so it attracts not just capital but incomers, enticed despite the high cost of living by the prospect of employment and, above all, a desire to be where they perceive the action to be.
For many, London's dominance is a mark of success, not failure, and something to be celebrated.


In this notebook, some template code has already been provided for you, and you will need to implement additional functionality to successfully complete this project. You will not need to modify the included code beyond what is requested. Sections that begin with '(IMPLEMENTATION)' in the header indicate that the following block of code will require additional functionality which you must provide. Instructions will be provided for each section, and the specifics of the implementation are marked in the code block with a 'TODO' statement. Please be sure to read the instructions carefully!
Note: Once you have completed all of the code implementations, you need to finalize your work by exporting the iPython Notebook as an HTML document. Before exporting the notebook to html, all of the code cells need to have been run so that reviewers can see the final implementation and output. You can then export the notebook by using the menu above and navigating to \n", "File -> Download as -> HTML (.html). Include the finished document along with this notebook as your submission.
In addition to implementing code, there will be questions that you must answer which relate to the project and your implementation. Each section where you will answer a question is preceded by a 'Question X' header. Carefully read each question and provide thorough answers in the following text boxes that begin with 'Answer:'. Your project submission will be evaluated based on your answers to each of the questions and the implementation you provide.
Note: Code and Markdown cells can be executed using the Shift + Enter keyboard shortcut. Markdown cells can be edited by double-clicking the cell to enter edit mode.
The rubric contains optional "Stand Out Suggestions" for enhancing the project beyond the minimum requirements. If you decide to pursue the "Stand Out Suggestions", you should include the code in this IPython notebook.
In this notebook, you will make the first steps towards developing an algorithm that could be used as part of a mobile or web app. At the end of this project, your code will accept any user-supplied image as input. If a dog is detected in the image, it will provide an estimate of the dog's breed. If a human is detected, it will provide an estimate of the dog breed that is most resembling. The image below displays potential sample output of your finished project (... but we expect that each student's algorithm will behave differently!).
In this real-world setting, you will need to piece together a series of models to perform different tasks; for instance, the algorithm that detects humans in an image will be different from the CNN that infers dog breed. There are many points of possible failure, and no perfect algorithm exists. Your imperfect solution will nonetheless create a fun user experience!
We break the notebook into separate steps. Feel free to use the links below to navigate the notebook.
In the code cell below, we import a dataset of dog images. We populate a few variables through the use of the load_files
function from the scikit-learn library:
train_files
, valid_files
, test_files
- numpy arrays containing file paths to imagestrain_targets
, valid_targets
, test_targets
- numpy arrays containing onehot-encoded classification labels dog_names
- list of string-valued dog breed names for translating labelsfrom sklearn.datasets import load_files
from keras.utils import np_utils
import numpy as np
from glob import glob
# define function to load train, test, and validation datasets
def load_dataset(path):
data = load_files(path)
dog_files = np.array(data['filenames'])
dog_targets = np_utils.to_categorical(np.array(data['target']), 133)
return dog_files, dog_targets
# load train, test, and validation datasets
train_files, train_targets = load_dataset('dogImages/train')
valid_files, valid_targets = load_dataset('dogImages/valid')
test_files, test_targets = load_dataset('dogImages/test')
# load list of dog names
dog_names = [item[20:-1] for item in sorted(glob("dogImages/train/*/"))]
# print statistics about the dataset
print('There are %d total dog categories.' % len(dog_names))
print('There are %s total dog images.\n' % len(np.hstack([train_files, valid_files, test_files])))
print('There are %d training dog images.' % len(train_files))
print('There are %d validation dog images.' % len(valid_files))
print('There are %d test dog images.'% len(test_files))
In the code cell below, we import a dataset of human images, where the file paths are stored in the numpy array human_files
.
import random
random.seed(8675309)
# load filenames in shuffled human dataset
human_files = np.array(glob("./lfw/*/*"))
random.shuffle(human_files)
# print statistics about the dataset
print('There are %d total human images.' % len(human_files))
We use OpenCV's implementation of Haar feature-based cascade classifiers to detect human faces in images. OpenCV provides many pre-trained face detectors, stored as XML files on github. We have downloaded one of these detectors and stored it in the haarcascades
directory.
In the next code cell, we demonstrate how to use this detector to find human faces in a sample image.
import cv2
import matplotlib.pyplot as plt
%matplotlib inline
# extract pre-trained face detector
face_cascade = cv2.CascadeClassifier('haarcascades/haarcascade_frontalface_alt.xml')
# load color (BGR) image
img = cv2.imread(human_files[3])
# convert BGR image to grayscale
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# find faces in image
faces = face_cascade.detectMultiScale(gray)
# print number of faces detected in the image
print('Number of faces detected:', len(faces))
# get bounding box for each detected face
for (x,y,w,h) in faces:
# add bounding box to color image
cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)
# convert BGR image to RGB for plotting
cv_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
# display the image, along with bounding box
plt.imshow(cv_rgb)
plt.show()
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray)
for (x,y,w,h) in faces:
# add bounding box to color image
cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)
cv_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
plt.imshow(cv_rgb)
plt.show()
Before using any of the face detectors, it is standard procedure to convert the images to grayscale. The detectMultiScale
function executes the classifier stored in face_cascade
and takes the grayscale image as a parameter.
In the above code, faces
is a numpy array of detected faces, where each row corresponds to a detected face. Each detected face is a 1D array with four entries that specifies the bounding box of the detected face. The first two entries in the array (extracted in the above code as x
and y
) specify the horizontal and vertical positions of the top left corner of the bounding box. The last two entries in the array (extracted here as w
and h
) specify the width and height of the box.
We can use this procedure to write a function that returns True
if a human face is detected in an image and False
otherwise. This function, aptly named face_detector
, takes a string-valued file path to an image as input and appears in the code block below.
# returns "True" if face is detected in image stored at img_path
def face_detector(img_path):
img = cv2.imread(img_path)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray)
return len(faces) > 0
Question 1: Use the code cell below to test the performance of the face_detector
function.
human_files
have a detected human face? dog_files
have a detected human face?  You will see that our algorithm falls short of this goal, but still gives acceptable performance. We extract the file paths for the first 100 images from each of the datasets and store them in the numpy arrays human_files_short
and dog_files_short
.
Answer:
human_files_short = human_files[:100]
dog_files_short = train_files[:100]
# Do NOT modify the code above this line.
## TODO: Test the performance of the face_detector algorithm
## on the images in human_files_short and dog_files_short.
human_res = [ face_detector(human_file) for human_file in human_files_short]
dog_res = [face_detector(dog_file) for dog_file in dog_files_short]
print('%s percentage of the fist 100 images in human_files have a detected human face' % np.sum(human_res) )
print('%s percentage of the fist 100 images in dog_files have a detected human face' % np.sum(dog_res) )
Question 2: This algorithmic choice necessitates that we communicate to the user that we accept human images only when they provide a clear view of a face (otherwise, we risk having unneccessarily frustrated users!). In your opinion, is this a reasonable expectation to pose on the user? If not, can you think of a way to detect humans in images that does not necessitate an image with a clearly presented face?
Answer:
We suggest the face detector from OpenCV as a potential way to detect human images in your algorithm, but you are free to explore other approaches, especially approaches that make use of deep learning :). Please use the code cell below to design and test your own face detection algorithm. If you decide to pursue this optional task, report performance on each of the datasets.
It is a way to expect users provide a clear view. But first of all, there will be human mistakes, we might not get the dataset we want. Secondly, this will reduce our dataset dramatically. We could use algorithm to select the dataset.
## (Optional) TODO: Report the performance of another
## face detection algorithm on the LFW dataset
### Feel free to use as many code cells as needed.
selected_human_files = [ human_file for human_file in human_files if face_detector(human_file)]
len(selected_human_files)
In this section, we use a pre-trained ResNet-50 model to detect dogs in images. Our first line of code downloads the ResNet-50 model, along with weights that have been trained on ImageNet, a very large, very popular dataset used for image classification and other vision tasks. ImageNet contains over 10 million URLs, each linking to an image containing an object from one of 1000 categories. Given an image, this pre-trained ResNet-50 model returns a prediction (derived from the available categories in ImageNet) for the object that is contained in the image.
from keras.applications.resnet50 import ResNet50
# define ResNet50 model
ResNet50_model = ResNet50(weights='imagenet')
When using TensorFlow as backend, Keras CNNs require a 4D array (which we'll also refer to as a 4D tensor) as input, with shape
$$ (\text{nb_samples}, \text{rows}, \text{columns}, \text{channels}), $$where nb_samples
corresponds to the total number of images (or samples), and rows
, columns
, and channels
correspond to the number of rows, columns, and channels for each image, respectively.
The path_to_tensor
function below takes a string-valued file path to a color image as input and returns a 4D tensor suitable for supplying to a Keras CNN. The function first loads the image and resizes it to a square image that is $224 \times 224$ pixels. Next, the image is converted to an array, which is then resized to a 4D tensor. In this case, since we are working with color images, each image has three channels. Likewise, since we are processing a single image (or sample), the returned tensor will always have shape
The paths_to_tensor
function takes a numpy array of string-valued image paths as input and returns a 4D tensor with shape
Here, nb_samples
is the number of samples, or number of images, in the supplied array of image paths. It is best to think of nb_samples
as the number of 3D tensors (where each 3D tensor corresponds to a different image) in your dataset!
from keras.preprocessing import image
from tqdm import tqdm
def path_to_tensor(img_path):
# loads RGB image as PIL.Image.Image type
img = image.load_img(img_path, target_size=(224, 224))
# convert PIL.Image.Image type to 3D tensor with shape (224, 224, 3)
x = image.img_to_array(img)
# convert 3D tensor to 4D tensor with shape (1, 224, 224, 3) and return 4D tensor
return np.expand_dims(x, axis=0)
def paths_to_tensor(img_paths):
list_of_tensors = [path_to_tensor(img_path) for img_path in tqdm(img_paths)]
return np.vstack(list_of_tensors)
Getting the 4D tensor ready for ResNet-50, and for any other pre-trained model in Keras, requires some additional processing. First, the RGB image is converted to BGR by reordering the channels. All pre-trained models have the additional normalization step that the mean pixel (expressed in RGB as $[103.939, 116.779, 123.68]$ and calculated from all pixels in all images in ImageNet) must be subtracted from every pixel in each image. This is implemented in the imported function preprocess_input
. If you're curious, you can check the code for preprocess_input
here.
Now that we have a way to format our image for supplying to ResNet-50, we are now ready to use the model to extract the predictions. This is accomplished with the predict
method, which returns an array whose $i$-th entry is the model's predicted probability that the image belongs to the $i$-th ImageNet category. This is implemented in the ResNet50_predict_labels
function below.
By taking the argmax of the predicted probability vector, we obtain an integer corresponding to the model's predicted object class, which we can identify with an object category through the use of this dictionary.
from keras.applications.resnet50 import preprocess_input, decode_predictions
def ResNet50_predict_labels(img_path):
# returns prediction vector for image located at img_path
img = preprocess_input(path_to_tensor(img_path))
return np.argmax(ResNet50_model.predict(img))
While looking at the dictionary, you will notice that the categories corresponding to dogs appear in an uninterrupted sequence and correspond to dictionary keys 151-268, inclusive, to include all categories from 'Chihuahua'
to 'Mexican hairless'
. Thus, in order to check to see if an image is predicted to contain a dog by the pre-trained ResNet-50 model, we need only check if the ResNet50_predict_labels
function above returns a value between 151 and 268 (inclusive).
We use these ideas to complete the dog_detector
function below, which returns True
if a dog is detected in an image (and False
if not).
### returns "True" if a dog is detected in the image stored at img_path
def dog_detector(img_path):
prediction = ResNet50_predict_labels(img_path)
return ((prediction <= 268) & (prediction >= 151))
Question 3: Use the code cell below to test the performance of your dog_detector
function.
human_files_short
have a detected dog? dog_files_short
have a detected dog?Answer:
### TODO: Test the performance of the dog_detector function
### on the images in human_files_short and dog_files_short.
human_res = [ dog_detector(human_file) for human_file in human_files_short]
dog_res = [dog_detector(dog_file) for dog_file in dog_files_short]
print('%s percentage of the fist 100 images in human_files have a detected dog face' % np.sum(human_res) )
print('%s percentage of the fist 100 images in dog_files have a detected dog face' % np.sum(dog_res) )
Now that we have functions for detecting humans and dogs in images, we need a way to predict breed from images. In this step, you will create a CNN that classifies dog breeds. You must create your CNN from scratch (so, you can't use transfer learning yet!), and you must attain a test accuracy of at least 1%. In Step 5 of this notebook, you will have the opportunity to use transfer learning to create a CNN that attains greatly improved accuracy.
Be careful with adding too many trainable layers! More parameters means longer training, which means you are more likely to need a GPU to accelerate the training process. Thankfully, Keras provides a handy estimate of the time that each epoch is likely to take; you can extrapolate this estimate to figure out how long it will take for your algorithm to train.
We mention that the task of assigning breed to dogs from images is considered exceptionally challenging. To see why, consider that even a human would have great difficulty in distinguishing between a Brittany and a Welsh Springer Spaniel.
| Brittany | Welsh Springer Spaniel |
|---|---|
It is not difficult to find other dog breed pairs with minimal inter-class variation (for instance, Curly-Coated Retrievers and American Water Spaniels).
| Curly-Coated Retriever | American Water Spaniel |
|---|---|
Likewise, recall that labradors come in yellow, chocolate, and black. Your vision-based algorithm will have to conquer this high intra-class variation to determine how to classify all of these different shades as the same breed.
| Yellow Labrador | Chocolate Labrador | Black Labrador |
|---|---|---|
We also mention that random chance presents an exceptionally low bar: setting aside the fact that the classes are slightly imabalanced, a random guess will provide a correct answer roughly 1 in 133 times, which corresponds to an accuracy of less than 1%.
Remember that the practice is far ahead of the theory in deep learning. Experiment with many different architectures, and trust your intuition. And, of course, have fun!
We rescale the images by dividing every pixel in every image by 255.
from PIL import ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True
# pre-process the data for Keras
train_tensors = paths_to_tensor(train_files).astype('float32')/255
valid_tensors = paths_to_tensor(valid_files).astype('float32')/255
test_tensors = paths_to_tensor(test_files).astype('float32')/255
Create a CNN to classify dog breed. At the end of your code cell block, summarize the layers of your model by executing the line:
model.summary()
We have imported some Python modules to get you started, but feel free to import as many modules as you need. If you end up getting stuck, here's a hint that specifies a model that trains relatively fast on CPU and attains >1% test accuracy in 5 epochs:
Question 4: Outline the steps you took to get to your final CNN architecture and your reasoning at each step. If you chose to use the hinted architecture above, describe why you think that CNN architecture should work well for the image classification task.
Answer:
I will just use the same model describe above. Since I don't know what is the best way to build the model.
The model above has 3 convolutional layers and 4 pooling layers. It makes sense to use pool layers after each convolutional layers to reduce parameters to fit. And the 3 convolutional layers contains more and more filters as the layers goes deeper, which I think is because we want to capture more and more details in each part of the image.
from keras.layers import Conv2D, MaxPooling2D, GlobalAveragePooling2D
from keras.layers import Dropout, Flatten, Dense
from keras.models import Sequential
model = Sequential()
### TODO: Define your architecture.
model.add(Conv2D(filters=16, kernel_size=2, padding='same', activation='relu',input_shape=(224, 224, 3)))
model.add(MaxPooling2D(pool_size=2))
model.add(Conv2D(filters=32, kernel_size=2, padding='same', activation='relu'))
model.add(MaxPooling2D(pool_size=2))
model.add(Conv2D(filters=64, kernel_size=2, padding='same', activation='relu'))
model.add(MaxPooling2D(pool_size=2))
model.add(Dropout(0.3))
model.add(Flatten())
model.add(Dense(500, activation='relu'))
model.add(Dropout(0.4))
model.add(Dense(133, activation='softmax'))
model.summary()
model.compile(optimizer='rmsprop', loss='categorical_crossentropy', metrics=['accuracy'])
Train your model in the code cell below. Use model checkpointing to save the model that attains the best validation loss.
You are welcome to augment the training data, but this is not a requirement.
from keras.callbacks import ModelCheckpoint
### TODO: specify the number of epochs that you would like to use to train the model.
epochs = 5
### Do NOT modify the code below this line.
checkpointer = ModelCheckpoint(filepath='saved_models/weights.best.from_scratch.hdf5',
verbose=1, save_best_only=True)
model.fit(train_tensors, train_targets,
validation_data=(valid_tensors, valid_targets),
epochs=epochs, batch_size=20, callbacks=[checkpointer], verbose=1)
model.load_weights('saved_models/weights.best.from_scratch.hdf5')
Try out your model on the test dataset of dog images. Ensure that your test accuracy is greater than 1%.
# get index of predicted dog breed for each image in test set
dog_breed_predictions = [np.argmax(model.predict(np.expand_dims(tensor, axis=0))) for tensor in test_tensors]
# report test accuracy
test_accuracy = 100*np.sum(np.array(dog_breed_predictions)==np.argmax(test_targets, axis=1))/len(dog_breed_predictions)
print('Test accuracy: %.4f%%' % test_accuracy)
bottleneck_features = np.load('bottleneck_features/DogVGG16Data.npz')
train_VGG16 = bottleneck_features['train']
valid_VGG16 = bottleneck_features['valid']
test_VGG16 = bottleneck_features['test']
The model uses the the pre-trained VGG-16 model as a fixed feature extractor, where the last convolutional output of VGG-16 is fed as input to our model. We only add a global average pooling layer and a fully connected layer, where the latter contains one node for each dog category and is equipped with a softmax.
VGG16_model = Sequential()
VGG16_model.add(GlobalAveragePooling2D(input_shape=train_VGG16.shape[1:]))
VGG16_model.add(Dense(133, activation='softmax'))
VGG16_model.summary()
VGG16_model.compile(loss='categorical_crossentropy', optimizer='rmsprop', metrics=['accuracy'])
checkpointer = ModelCheckpoint(filepath='saved_models/weights.best.VGG16.hdf5',
verbose=1, save_best_only=True)
VGG16_model.fit(train_VGG16, train_targets,
validation_data=(valid_VGG16, valid_targets),
epochs=20, batch_size=20, callbacks=[checkpointer], verbose=1)
VGG16_model.load_weights('saved_models/weights.best.VGG16.hdf5')
Now, we can use the CNN to test how well it identifies breed within our test dataset of dog images. We print the test accuracy below.
# get index of predicted dog breed for each image in test set
VGG16_predictions = [np.argmax(VGG16_model.predict(np.expand_dims(feature, axis=0))) for feature in test_VGG16]
# report test accuracy
test_accuracy = 100*np.sum(np.array(VGG16_predictions)==np.argmax(test_targets, axis=1))/len(VGG16_predictions)
print('Test accuracy: %.4f%%' % test_accuracy)
from extract_bottleneck_features import *
def VGG16_predict_breed(img_path):
# extract bottleneck features
bottleneck_feature = extract_VGG16(path_to_tensor(img_path))
# obtain predicted vector
predicted_vector = TN_model.predict(bottleneck_feature)
# return dog breed that is predicted by the model
return dog_names[np.argmax(predicted_vector)]
You will now use transfer learning to create a CNN that can identify dog breed from images. Your CNN must attain at least 60% accuracy on the test set.
In Step 4, we used transfer learning to create a CNN using VGG-16 bottleneck features. In this section, you must use the bottleneck features from a different pre-trained model. To make things easier for you, we have pre-computed the features for all of the networks that are currently available in Keras:
The files are encoded as such:
Dog{network}Data.npz
where {network}
, in the above filename, can be one of VGG19
, Resnet50
, InceptionV3
, or Xception
. Pick one of the above architectures, download the corresponding bottleneck features, and store the downloaded file in the bottleneck_features/
folder in the repository.
In the code block below, extract the bottleneck features corresponding to the train, test, and validation sets by running the following:
bottleneck_features = np.load('bottleneck_features/Dog{network}Data.npz')
train_{network} = bottleneck_features['train']
valid_{network} = bottleneck_features['valid']
test_{network} = bottleneck_features['test']
### TODO: Obtain bottleneck features from another pre-trained CNN.
network = 'Resnet50'
bottleneck_features = np.load('bottleneck_features/Dog%sData.npz' % network)
train_TN = bottleneck_features['train']
valid_TN = bottleneck_features['valid']
test_TN = bottleneck_features['test']
Create a CNN to classify dog breed. At the end of your code cell block, summarize the layers of your model by executing the line:
<your model's name>.summary()
Question 5: Outline the steps you took to get to your final CNN architecture and your reasoning at each step. Describe why you think the architecture is suitable for the current problem.
Answer:
train_TN[0].shape
#train_tensors[0].shape
I think I should use the simplest learning to adjust the well established CNN. That's why I keep using the average pooling layer.
And I tried to increase the epochs to learn, the accuracy got improved.
### TODO: Define your architecture.
TN_model = Sequential()
TN_model.add(GlobalAveragePooling2D(input_shape=train_TN.shape[1:]))
TN_model.add(Dropout(0.2))
TN_model.add(Dense(133, activation='softmax'))
TN_model.summary()
### TODO: Compile the model.
TN_model.compile(loss='categorical_crossentropy', optimizer='rmsprop', metrics=['accuracy'])
Train your model in the code cell below. Use model checkpointing to save the model that attains the best validation loss.
You are welcome to augment the training data, but this is not a requirement.
## TODO: Train the model.
checkpointer = ModelCheckpoint(filepath='saved_models/weights.best.TN.hdf5',
verbose=1, save_best_only=True)
TN_model.fit(train_TN, train_targets, validation_data=(valid_TN, valid_targets),
epochs=30, batch_size=20, callbacks=[checkpointer], verbose=1)
### TODO: Load the model weights with the best validation loss.
TN_model.load_weights('saved_models/weights.best.TN.hdf5')
Try out your model on the test dataset of dog images. Ensure that your test accuracy is greater than 60%.
### TODO: Calculate classification accuracy on the test dataset.
TN_predictions = [np.argmax(TN_model.predict(np.expand_dims(feature, axis=0))) for feature in test_TN]
# report test accuracy
test_accuracy = 100*np.sum(np.array(TN_predictions)==np.argmax(test_targets, axis=1))/len(TN_predictions)
print('Test accuracy: %.4f%%' % test_accuracy)
Write a function that takes an image path as input and returns the dog breed (Affenpinscher
, Afghan_hound
, etc) that is predicted by your model.
Similar to the analogous function in Step 5, your function should have three steps:
dog_names
array defined in Step 0 of this notebook to return the corresponding breed.The functions to extract the bottleneck features can be found in extract_bottleneck_features.py
, and they have been imported in an earlier code cell. To obtain the bottleneck features corresponding to your chosen CNN architecture, you need to use the function
extract_{network}
where {network}
, in the above filename, should be one of VGG19
, Resnet50
, InceptionV3
, or Xception
.
### TODO: Write a function that takes a path to an image as input
### and returns the dog breed that is predicted by the model.
from extract_bottleneck_features import *
def TN_predict_breed(img_path):
# extract bottleneck features
bottleneck_feature = extract_Resnet50(path_to_tensor(img_path))
# obtain predicted vector
predicted_vector = TN_model.predict(bottleneck_feature)
# return dog breed that is predicted by the model
return dog_names[np.argmax(predicted_vector)]
Write an algorithm that accepts a file path to an image and first determines whether the image contains a human, dog, or neither. Then,
You are welcome to write your own functions for detecting humans and dogs in images, but feel free to use the face_detector
and dog_detector
functions developed above. You are required to use your CNN from Step 5 to predict dog breed.
Some sample output for our algorithm is provided below, but feel free to design your own user experience!
### TODO: Write your algorithm.
### Feel free to use as many code cells as needed.
def overall_detection_algorithhm(file_path):
if face_detector(file_path) or dog_detector(file_path):
return TN_predict_breed(file_path)
else:
return 'ERROR'
In this section, you will take your new algorithm for a spin! What kind of dog does the algorithm think that you look like? If you have a dog, does it predict your dog's breed accurately? If you have a cat, does it mistakenly think that your cat is a dog?
Test your algorithm at least six images on your computer. Feel free to use any images you like. Use at least two human and two dog images.
Question 6: Is the output better than you expected :) ? Or worse :( ? Provide at least three possible points of improvement for your algorithm.
Answer:
The results are OK. For human, it's even trying to get similar looking dogs. To improve:
## TODO: Execute your algorithm from Step 6 on
## at least 6 images on your computer.
## Feel free to use as many code cells as needed.
import random
human_set = random.sample(list(human_files), 3)
dog_set = random.sample(list(train_files), 3)
for file_item in (human_set + dog_set):
img = cv2.imread(file_item)
cv_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
plt.imshow(cv_rgb)
plt.show()
print('Detection results is', overall_detection_algorithhm(file_item))
human_files


Yacht with 74 illegal migrants and two Ukrainian crew on board found off Italy coast
The two men are facing prosecution for soliciting illegal migration.
A yacht with 74 illegal immigrants on board was found off the coast of Italy.
The vessel was operated by two Ukrainian nationals, as reported by the press office of the State Border Guard Service of Ukraine.
"Recently, the SBGS received confirmation of the fact that, on a tip provided by Europol about a boat that could be used in illegal activities, the Italian coast guard stopped the drifting yacht," the report said.
"On board the small ship were as many as 74 passengers who identified as Iraqi citizens. The crew of the yacht consisted of two Ukrainians, born in 1980 and 1988. The Italian police arrested our compatriots for facilitating illegal migration," the SBGS reports.
The State Border Guard Service of Ukraine, together with the National Police and Europol, are taking active measures to counter this type of criminal activity. Investigative actions are underway, with an ultimate goal of bringing to justice the persons, including foreign citizens, involved in attracting Ukrainian citizens to criminal activities abroad.
The agency has called on citizens of Ukraine to carefully study job offers of a dubious nature so as not to become victims of criminals.


1. Fill out the form on the right
2. Submit it, and use browser back button to come back here
3. The form is now prefilled with your previous data (mimic autocomplete)
Now, start the Conversation to see the mapped values
Video of auto-complete features
Native form
Choose your favourite social channel
Facebook
Ello
Twitter
Your FIRST name
Your LAST name
Your email
Submit