-
Notifications
You must be signed in to change notification settings - Fork 1
/
image_choose.py
72 lines (62 loc) · 1.53 KB
/
image_choose.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
from genericpath import isfile
from importlib.resources import path
from inspect import getattr_static
import os
from pyexpat import features
import time
import re
import hashlib
import pickle
import copy
from turtle import color
import pandas as pd
from tkinter import W
import uuid
import numpy as np
import torch
import click
import dnnlib
import torchvision
import scipy.linalg
import cv2
import pickle
from training import dataset
import torch.nn.functional as F
from torch.utils import data
from PIL import Image
from matplotlib import pyplot as plt
from torchvision import transforms,datasets
from torchsummary import summary
from sqrtm import sqrtm
from visualizer import *
from torchvision.io import read_image
from torch.utils.data import DataLoader
cache_path = '~/.cache'
_feature_detector_cache = dict()
#load data
rank=0
N=20000000
device = 'cuda'
def choose(real_image_dataset):
number=0
files=os.listdir(real_image_dataset)
fid_cams=[]
for f in files:
fname=os.path.join(real_image_dataset,f)
try:
img = Image.open(fname)
except:
print('ReadError, Path:', fname)
#os.remove(fname)
number+=1
return number
@click.command()
@click.option('--real_dataset', help='Generated dataset to evaluate', type=str, default=None, metavar='[ZIP|DIR]', show_default=True)
def image_choose(
real_dataset: str,
):
real_dataset_url=real_dataset
res=choose(real_dataset_url)
print(res)
if __name__ == "__main__":
image_choose()