Code for the Make Your Own Neural Network book
makeyourownneuralnetwork / gan Goto Github PK
View Code? Open in Web Editor NEWpython notebooks accompanying the book Make Your Own GAN
License: GNU General Public License v2.0
python notebooks accompanying the book Make Your Own GAN
License: GNU General Public License v2.0
Code for the Make Your Own Neural Network book
First of all, I really enjoy reading "Make Your First GAN with PyTorch." The book explains the idea behind GAN and its training clearly. A wonderful book for anyone who is interested in this subject.
I'm creating this ticket because I was having issue accessing the CelebA dataset following the book's instructions. The issue seems to be caused by the imageio
package. In particular, I got the following error:
`ValueError: Could not find a backend to open `/Users/cchang/Projects/torch/celeba_data/__MACOSX/img_align_celeba/._052628.jpg`` with iomode `ri`.
Based on the extension, the following plugins might add capable backends:
pyav: pip install imageio[pyav]
opencv: pip install imageio[opencv]`
I installed the plugins as instructed, then this came up:
`ValueError: Could not find a backend to open `xxx.jpg` with iomode `ri`.`
Anyhow, in order to proceed, I decided to download the CelebA dataset from the source (either from the link provided in the book or from kaggle), and created the h5py file as follows:
import matplotlib.image as mpimg
hdf5_file = 'celeba_aligned_small.h5py'
with h5py.File(hdf5_file, 'w') as hf:
for i in range(1, 20000):
img = mpimg.imread('./img_align_celeba/{0:06d}.jpg'.format(i))
hf.create_dataset('img_align_celeba/{0:06d}.jpg'.format(i),
data=img,
compression="gzip",
compression_opts=9)
if (i%1000 == 0):
print("images done .. ", count)
pass
Note that
matplotlib
's image class for reading the CelebA image files. There are many other options available for this.CelebADataset()
class needs a little adjustment for the convention.Hope this can be of a little help for those who also encountered a similar issue.
Running this notebook in Google Colab results in the following error:
BadZipFile Traceback (most recent call last)
in ()
1 # download data
2
----> 3 mnist_dataset = torchvision.datasets.CelebA(root='.', download=True)
3 frames
/usr/lib/python3.6/zipfile.py in _RealGetContents(self)
1196 raise BadZipFile("File is not a zip file")
1197 if not endrec:
-> 1198 raise BadZipFile("File is not a zip file")
1199 if self.debug > 1:
1200 print(endrec)
BadZipFile: File is not a zip file
with h5py.File('mount/My Drive/Colab Notebooks/myo_gan/
celeba_dataset/celeba_aligned_small.h5py', 'r') as file_object:
for group in file_object:
print(group)
pass
I suppose it should be CrossEntropyLoss instead of BCELoss since MNIST is 10-class classification?
Hello,
first of all thank you very much for your books. I hope to see more and as soon as passible :).
I have a problem with downloading of celeba dataset. I will just continue on my own hardware, but wanted to share the issue
`BadZipFile Traceback (most recent call last)
in ()
1
----> 2 mnist_dataset = torchvision.datasets.CelebA(root='.', download=True)
3 frames
/usr/lib/python3.6/zipfile.py in _RealGetContents(self)
1196 raise BadZipFile("File is not a zip file")
1197 if not endrec:
-> 1198 raise BadZipFile("File is not a zip file")
1199 if self.debug > 1:
1200 print(endrec)
BadZipFile: File is not a zip file`
方法 'Discriminator.train()' 的签名与类 'Module' 中基方法的签名不匹配
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.