-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from FrancescoSaverioZuppichini/develop
Develop
- Loading branch information
Showing
39 changed files
with
786 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
.idea/ | ||
__pycache__/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from mirror.visualisations.Visualisation import Visualisation | ||
|
||
class DummyVisualisation(Visualisation): | ||
|
||
def __call__(self, inputs, layer): | ||
return inputs.repeat(self.params['repeat']['value'],1, 1, 1) | ||
|
||
@property | ||
def name(self): | ||
return 'dummy' | ||
|
||
def init_params(self): | ||
return {'repeat' : { | ||
'type' : 'slider', | ||
'min' : 1, | ||
'max' : 100, | ||
'value' : 3, | ||
'step': 1, | ||
'params': {} | ||
}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
from mirror import mirror | ||
from mirror.visualisations import DeepDream | ||
|
||
from PIL import Image | ||
|
||
from torchvision.models import resnet101 | ||
from torchvision.models import resnet101, resnet18, vgg16 | ||
from torchvision.transforms import ToTensor, Resize, Compose | ||
|
||
model = resnet101(True) | ||
|
||
cat = Image.open("cat.jpg") | ||
# create a model | ||
model = vgg16(pretrained=True) | ||
|
||
cat = Image.open("./cat.jpg") | ||
# resize the image and make it a tensor | ||
input = Compose([Resize((224,224)), ToTensor()])(cat) | ||
|
||
input = input.view(1,3,224,224) | ||
|
||
mirror(input, model) | ||
# add 1 dim for batch | ||
input = input.unsqueeze(0) | ||
# call mirror with the input and the model | ||
mirror(input, model, visualisations=[DeepDream]) |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.