当前位置:网站首页>Is index reproduction text generation image is score quantitative experiment whole process reproduction inception score quantitative evaluation experiment step on the pit and avoid the pit process
Is index reproduction text generation image is score quantitative experiment whole process reproduction inception score quantitative evaluation experiment step on the pit and avoid the pit process
2022-07-27 02:08:00 【Medium coke with ice】
Catalog
- One 、IS Introduction to scores
- Two 、IS fraction CUB Quantitative experiment steps
- First step :B_VALIDATION Change it to True
- The second step : Configure the trained generator
- The third step : Sampling generates images
- Step four : download IS Code and configure
- Step five : Download pre trained inception mode And configuration
- Step six : To configure inception_score.py, Change the read path
- Step seven : Start quantitative evaluation
- Last
One 、IS Introduction to scores
The evaluation of text generated images is also a very challenging work ,IS Score is a general index to measure image quality .
IS Yes KL Mathematical knowledge of divergence and entropy , Its main principle is to calculate p(y|x) and p(y) The divergence between ,IS The higher the score, the better .
Two 、IS fraction CUB Quantitative experiment steps
With DF-GAN As an example :
First step :B_VALIDATION Change it to True
according to DF-GAN Official documents of , First of all, will bird.yml Medium B_VALIDATION Change it to True:
The second step : Configure the trained generator
Configure trained model, And put it in code/bird in , Rename it to netG.pth,DF-GAN The official also gave a well-trained model : The official link , Those who cannot open the official link can click CSDN link , After downloading, put it into the specified folder .
The third step : Sampling generates images
function :python main.py --cfg cfg/bird.yml
Possible problems 1:RuntimeError: Attempting to deserialize object on CUDA device
1 but torch.cuda.device_count() is 1
Question why : The model uses several blocks during training GPU, But this machine only 1 block GPU
Solution : Designated for “cuda:0”, Find two torch.load()
The first place is main.py Of the 57 That's ok :netG.load_state_dict(torch.load('models/%s/netG.pth' % (cfg.CONFIG_NAME))Change it to :netG.load_state_dict(torch.load('models/%s/netG.pth' % (cfg.CONFIG_NAME), map_location='cuda:0'))
The second place is the second 254 Change it to :state_dict = torch.load(cfg.TEXT.DAMSM_NAME, map_location='cuda:0')
Possible problems 2:
RuntimeError: Error(s) in loading state_dict for NetG:
size mismatch for fc.weight: copying a param with shape torch.Size([4096, 100]) from checkpoint, the shape in current model is torch.Size([1024, 100]).
size mismatch for fc.bias: copying a param with shape torch.Size([4096]) from checkpoint, the shape in current model is torch.Size([1024]).
size mismatch for block0.c1.weight: copying a param with shape torch.Size([256, 256, 3, 3]) from checkpoint, the shape in current model is torch.Size([64, 64, 3, 3])
Question why : When loading the model , The parameter does not correspond to , Size mismatch
Solution : Check the trained model model.py And do quantitative at this time model.py Whether or not the same , see yml Whether the size of the file is set the same , especially NF Parameter settings . If used DF-GAN Officially trained models , To put NF Set to 32, Others should also be consistent :
After successful operation , It will automatically sample and generate several pictures , The successful 
Step four : download IS Code and configure
Official IS fraction (StackGAN Used ) Code :github link , Put it in the folder in the following location :
Step five : Download pre trained inception mode And configuration
Download pre trained inception model: The official link 、 If you can't open it, you can click :CSDN link , Put it in the specified location of the folder , The location is as follows :

Step six : To configure inception_score.py, Change the read path
open inception_score.py Code for , Locate the 41 Row to 49 That's ok :
You can see that there are two file addresses , The first address indicates where to read the pre trained inception model checkpoints, Change it to your own path :
tf.app.flags.DEFINE_string('checkpoint_dir',
'../birds_valid299/model.ckpt',
"""Path where to read model checkpoints.""")
The second path refers to where to read the sampled pictures , Also change it to your own path :
tf.app.flags.DEFINE_string('image_folder',
'../test/valid/single',
"""Path where to load the images """)
Step seven : Start quantitative evaluation
Input... At the terminal :python inception_score.py --image_folder ../test/valid/single
It is shown as follows :
It's done , It can be seen that the result of this time is 4.61, Error is ±0.13!
Last
Personal profile : Graduate students in the field of artificial intelligence , At present, I mainly focus on text generation and image generation (text to image) Direction
Personal home page : Medium coke with more ice
Time limited free subscribe : Text generated images T2I special column
Stand by me : give the thumbs-up + Collection ️+ Leaving a message.
If this article helps you a lot , I hope you can give me a coke ! Add more ice
边栏推荐
- mysql优化概论
- Talking about server virtualization & hyper convergence & Storage
- [FPGA tutorial case 30] DDS direct digital frequency synthesizer based on FPGA -- frequency accuracy analysis with MATLAB
- 2022最新直播监控24小时监控(三)直播间弹幕解析
- mysql的安装
- ViTGAN:用视觉Transformer训练生成性对抗网络 Training GANs with Vision Transformers
- [translation] reduced precision in tensorrt
- Unity Huatuo example project source code analysis and inspiration
- D - Difference HDU - 5936
- [详解C语言]一文带你玩转函数
猜你喜欢
随机推荐
三种能有效融合文本和图像信息的方法——特征拼接、跨模态注意、条件批量归一化
科学计算库 —— Matplotlib
为啥不建议使用Select *
6.28同花顺笔试
高度塌陷解决方法
MySQL单表查询练习
a元素的伪类
Machine learning exercise 7 - K-means and PCA (principal component analysis)
Pseudo class of a element
【数据库课程设计】SQLServer数据库课程设计(学生宿舍管理),课设报告+源码+数据库关系图
Use of GDB
7.16 多益网络笔试
[untitled]
Fastjson handles string escape characters
[paddleseg source code reading] paddleseg export static graph export Trace in py file
Shell programming specifications and variables
25pxe efficient batch network installation
TIM输出比较——PWM
(codeforce 807div2)C. Mark and his unfinished essay (thinking)
7.7 SHEIN希音笔试






![[reprint] GPU compute capability table](/img/7c/87be1131f52f21fe080c36f0834467.png)

![[详解C语言]一文带你玩转函数](/img/44/53cdac9b9cf0d3f77e5da05956c3dc.png)
