Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- fetch_sample_images.py +53 -0
- requirements.txt +17 -0
- samples_index.py +61 -0
fetch_sample_images.py
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import io
|
2 |
+
import os
|
3 |
+
import cv2
|
4 |
+
import tqdm
|
5 |
+
import numpy
|
6 |
+
import requests
|
7 |
+
|
8 |
+
|
9 |
+
def get_bytes(x: str):
|
10 |
+
return numpy.frombuffer(requests.get(x).content, numpy.uint8)
|
11 |
+
|
12 |
+
|
13 |
+
def get_image(x):
|
14 |
+
return cv2.imdecode(get_bytes(x), cv2.IMREAD_COLOR)
|
15 |
+
|
16 |
+
|
17 |
+
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
18 |
+
# classification
|
19 |
+
# uids = """
|
20 |
+
# a784af0713a643b19ffcf65194bc0fbf
|
21 |
+
# 569a71ccf4d94c1585c9573521fb998f
|
22 |
+
# 4e6d591f6e50493aa5e31355084fc4e8
|
23 |
+
# """.split()
|
24 |
+
|
25 |
+
# caption
|
26 |
+
# uids = """
|
27 |
+
# 283c845f2c2c4567971d42dc46831372
|
28 |
+
# fc655111af5b49bf84722affc3ddba00
|
29 |
+
# fa17099f18804409bc6d9e8e397b4681
|
30 |
+
# d3c0e3495b5d40d087a7f82d1690b9cb
|
31 |
+
# 4b27adcf92f644bdabf8ecc6c5bef399
|
32 |
+
# f8c13a19e84343e7b644c19f7b9488d3
|
33 |
+
# """.split()
|
34 |
+
|
35 |
+
# sd
|
36 |
+
uids = """
|
37 |
+
b464ff8d732d44fab00b903652c8274e
|
38 |
+
efae586a477b49cea1a0777487cc2df3
|
39 |
+
f8272460c67d476a8af29e1f2e344bc0
|
40 |
+
ff2875fb1a5b4771805a5fd35c8fe7bb
|
41 |
+
b8db8dc5caad4fa5842a9ed6dbd2e9d6
|
42 |
+
tpvzmLUXAURQ7ZxccJIBZvcIDlr
|
43 |
+
""".split()
|
44 |
+
|
45 |
+
|
46 |
+
uri_fmt = 'https://objaverse-thumbnail-images.s3.us-west-2.amazonaws.com/{}.jpg'
|
47 |
+
for u in tqdm.tqdm(uids):
|
48 |
+
img = get_image(uri_fmt.format(u))
|
49 |
+
max_edge = max(img.shape)
|
50 |
+
if max_edge > 512:
|
51 |
+
s = 512 / max_edge
|
52 |
+
img = cv2.resize(img, [0, 0], fx=s, fy=s, interpolation=cv2.INTER_CUBIC)
|
53 |
+
cv2.imwrite("samples/sd/%s.jpg" % u, img)
|
requirements.txt
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
--extra-index-url https://download.pytorch.org/whl/cu113
|
2 |
+
torch
|
3 |
+
-f https://data.dgl.ai/wheels/repo.html
|
4 |
+
dgl-cu113
|
5 |
+
numpy
|
6 |
+
# open_clip_torch
|
7 |
+
diffusers
|
8 |
+
accelerate
|
9 |
+
datasets
|
10 |
+
transformers==4.29.2
|
11 |
+
einops
|
12 |
+
torch.redstone
|
13 |
+
objaverse
|
14 |
+
altair<5
|
15 |
+
trimesh
|
16 |
+
matplotlib
|
17 |
+
plotly
|
samples_index.py
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
+
|
4 |
+
cap_base = 'samples/caption'
|
5 |
+
cap = [
|
6 |
+
dict(cap_objaid=os.path.splitext(x)[0], dispi=os.path.join(cap_base, x))
|
7 |
+
for x in sorted(os.listdir(cap_base))
|
8 |
+
]
|
9 |
+
|
10 |
+
cls_base = 'samples/classification'
|
11 |
+
classification = [
|
12 |
+
dict(cls_objaid=os.path.splitext(x)[0], dispi=os.path.join(cls_base, x))
|
13 |
+
for x in sorted(os.listdir(cls_base))
|
14 |
+
]
|
15 |
+
|
16 |
+
sd_base = 'samples/sd'
|
17 |
+
sd_texts = {
|
18 |
+
'b8db8dc5caad4fa5842a9ed6dbd2e9d6': 'falcon',
|
19 |
+
'ff2875fb1a5b4771805a5fd35c8fe7bb': 'in the woods',
|
20 |
+
'tpvzmLUXAURQ7ZxccJIBZvcIDlr': 'above the fields'
|
21 |
+
}
|
22 |
+
sd = [
|
23 |
+
dict(
|
24 |
+
sd_objaid=os.path.splitext(x)[0],
|
25 |
+
dispi=os.path.join(sd_base, x),
|
26 |
+
sdtprompt=sd_texts.get(os.path.splitext(x)[0], '')
|
27 |
+
)
|
28 |
+
for x in sorted(os.listdir(sd_base))
|
29 |
+
]
|
30 |
+
|
31 |
+
retrieval_texts = """
|
32 |
+
shark
|
33 |
+
swordfish
|
34 |
+
dolphin
|
35 |
+
goldfish
|
36 |
+
high heels
|
37 |
+
boots
|
38 |
+
slippers
|
39 |
+
sneakers
|
40 |
+
tiki mug
|
41 |
+
viking mug
|
42 |
+
animal-shaped mug
|
43 |
+
travel mug
|
44 |
+
white conical mug
|
45 |
+
green cubic mug
|
46 |
+
blue spherical mug
|
47 |
+
orange cylinder mug
|
48 |
+
""".splitlines()
|
49 |
+
retrieval_texts = [x.strip() for x in retrieval_texts if x.strip()]
|
50 |
+
|
51 |
+
pret_base = 'samples/retrieval-pc'
|
52 |
+
pret = [
|
53 |
+
dict(retpc_objaid=os.path.splitext(x)[0], dispi=os.path.join(pret_base, x))
|
54 |
+
for x in sorted(os.listdir(pret_base))
|
55 |
+
]
|
56 |
+
|
57 |
+
iret_base = 'samples/retrieval-img'
|
58 |
+
iret = [
|
59 |
+
dict(rimageinput=os.path.join(iret_base, x), dispi=os.path.join(iret_base, x))
|
60 |
+
for x in sorted(os.listdir(iret_base))
|
61 |
+
]
|