Comments (7)
sir, How to do prediction on single image?
Hey,
If you are following along the Colab notebook, you can use the following code snippet to do prediction on a single image and visualize the final result. Note that you need to define the model (as noted in the notebook) and load the pretrained weights that I've provided there:
img = PIL.Image.open("black_and_white.jpg")
img = img.resize((256, 256))
# to make it between -1 and 1
img = transforms.ToTensor()(img)[:1] * 2. - 1.
model.eval()
with torch.no_grad():
preds = model.net_G(img.unsqueeze(0).to(device))
plt.imshow(lab_to_rgb(img.unsqueeze(0), preds.cpu())[0])
I hope this helps you out. Please let me know if there is any problem. Good Luck!
from deep-learning.
thanks it worked
from deep-learning.
from deep-learning.
from deep-learning.
from deep-learning.
sir, How to do prediction on single image?
Hey,
If you are following along the Colab notebook, you can use the following code snippet to do prediction on a single image and visualize the final result. Note that you need to define the model (as noted in the notebook) and load the pretrained weights that I've provided there:
img = PIL.Image.open("black_and_white.jpg") img = img.resize((256, 256)) # to make it between -1 and 1 img = transforms.ToTensor()(img)[:1] * 2. - 1. model.eval() with torch.no_grad(): preds = model.net_G(img.unsqueeze(0).to(device)) plt.imshow(lab_to_rgb(img.unsqueeze(0), preds.cpu())[0])
I hope this helps you out. Please let me know if there is any problem. Good Luck!
Why we transforms it between -1 and 1 and not 0 1
from deep-learning.
Why we transforms it between -1 and 1 and not 0 1
@radudiaconu0
The model has been trained in this way so the evaluation must be done in the same way.
The generator architecture contains a Tanh function in the last layer, so, the generated image is between -1 and 1. So, the real images coming to discriminator should be in the same range. That's the reason why we scale between -1 and 1 in the dataset.
from deep-learning.
Related Issues (9)
- Issue with running infer file
- AttributeError: 'function' object has no attribute 'named_parameters' HOT 3
- can't create the body of ResNet18 HOT 3
- The code takes 4h foe each epoch in google colab. HOT 3
- Error on pretrain_generator HOT 3
- Code for using the trained model... HOT 7
- PyTorch Lightning implementation
- How to test the code on custom data? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deep-learning.