Comments (16)
Hi @cherryolg.
Did yo manage to figure this out?
Thanks.
later edit: i just modified the testing script to read the images directly from a folder, instead of taking the images name from a csv file. hope it helps.
from neural-image-assessment.
@Ellyuca Can you share the script?
from neural-image-assessment.
Hi @RamishRasool14 . I think this was it. It has been some time since I last used it. Let me know if it works. Basically I just skip the step where I read the data from the .csv file and just read the images from a folder.
import argparse
import os
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
import pandas as pd
from tqdm import tqdm
import torch
import torchvision.models as models
import torchvision.transforms as transforms
from model.model import *
parser = argparse.ArgumentParser()
parser.add_argument('--model', type=str, help='path to pretrained model')
#parser.add_argument('--test_csv', type=str, help='test csv file')
parser.add_argument('--test_images', type=str, help='path to folder containing images')
parser.add_argument('--workers', type=int, default=4, help='number of workers')
parser.add_argument('--predictions', type=str, help='output file to store predictions')
args = parser.parse_args()
base_model = models.vgg16(pretrained=True)
model = NIMA(base_model)
try:
model.load_state_dict(torch.load(args.model))
print('successfully loaded model')
except:
raise
seed = 42
torch.manual_seed(seed)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = model.to(device)
model.eval()
test_transform = transforms.Compose([
transforms.Resize(256),
#transforms.RandomCrop(224),
transforms.CenterCrop(224),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225])
])
testing_imgs = args.test_images
print("testing_imgs:", os.listdir(testing_imgs))
images_list = os.listdir(testing_imgs)
mean, std = 0.0, 0.0
for i,img in enumerate(images_list):
print("here:", i,img)
im = Image.open(os.path.join("/content/some_original_images", str(img))) #the path to the folder with images
im = im.convert('RGB')
imt = test_transform(im)
imt = imt.unsqueeze(dim=0)
imt = imt.to(device)
with torch.no_grad():
out = model(imt)
out = out.view(10, 1)
for j, e in enumerate(out, 1):
mean += j * e
for k, e in enumerate(out, 1):
std += e * (k - mean) ** 2
std = std ** 0.5
if not os.path.exists(args.predictions):
os.makedirs(args.predictions)
with open(os.path.join(args.predictions, 'my_pred.txt'), 'a') as f:
f.write(str(img) + ' mean: %.3f | std: %.3f\n' % (mean, std))
mean, std = 0.0, 0.0
#pbar.update()
from neural-image-assessment.
Thank you very much @Ellyuca I will let you know if this works. Also do you have a pre-trained checkpoint for this, your own or if you happen to have downloaded from the provided now broken drive link?
from neural-image-assessment.
Hi @RamishRasool14.
This is the checkpoint that I have downloaded a while back:
https://file.io/77S7MMB5a631
from neural-image-assessment.
Hello @Ellyuca
can you please upload again. i think it is a 1 time download link
from neural-image-assessment.
@RamishRasool14 try this: https://file.io/20aCY0s7alu5 or this:https://easyupload.io/djns9e
from neural-image-assessment.
Hello @Ellyuca
Wanted to let you know the code and checkpoints are working fine and thank you for sharing it with me. Just had to made minor adjustments to the code with the absolute path because you had changed it for your machine. Rest it is working perfect. Thanks again!
from neural-image-assessment.
Hi @RamishRasool14 .
Glad I could help out!
from neural-image-assessment.
@RamishRasool14 try this: https://file.io/20aCY0s7alu5 or this:https://easyupload.io/djns9e
Hi @Ellyuca, I encountered a similar problem, could you please send me a link?
from neural-image-assessment.
@Joy-liningqiao
I think this was the pretrained model.
https://file.io/xAOhkOVNUg06
from neural-image-assessment.
from neural-image-assessment.
from neural-image-assessment.
Hi @Joy-liningqiao.
I can resend it to you tomorrow morning. I don't have access to it atm.
I'll try to put it on Google drive and leave the link available.
from neural-image-assessment.
from neural-image-assessment.
Hi @Joy-liningqiao,
here is the link to the model: https://drive.google.com/drive/folders/1WvWWj7_U8pcoFRQnJ-4uaoBuICbHlz3A?usp=sharing
Let me know if you are able to download it, otherwise I will look for another solution.
from neural-image-assessment.
Related Issues (20)
- hi, my training process looks OK, the final loss is about 0.0988. but the result seems random HOT 1
- fully connected layers HOT 2
- About AVA dataset HOT 8
- Some mistake in main.py
- It requires me to install so much packages
- No such file or directory - Please Help HOT 6
- The torchvision pretrained VGG-16 requires normalization of inputs and you do not do this HOT 3
- 你好,我没有训练模型的硬件条件,但是还是想用图像美学。可以分享一下,训练好的权重文件吗??? HOT 1
- how to test myself photo? HOT 2
- Is there pretrained weight for InceptionNet?
- The score for the same picture varies HOT 5
- the google drive link for pretrained model is invalid HOT 8
- The link to the pre-trained model is not working HOT 9
- About the test.py
- csv文件
- AVA dataset download
- userwaring: possibly corrupt EXIF data
- Pre-trained model link not working HOT 1
- who can share the pre-train model? 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 neural-image-assessment.