Spaces:
Sleeping
Sleeping
Update dl.py
Browse files
dl.py
CHANGED
|
@@ -36,7 +36,6 @@ def show_f(repo,name,token):
|
|
| 36 |
#file_out = []
|
| 37 |
if not os.path.exists(name):
|
| 38 |
os.makedirs(name)
|
| 39 |
-
images = [".png" , ".jpg" , ".gif" , ".webm" , ".mp4"]
|
| 40 |
for d_app in f_ist:
|
| 41 |
if "/" in d_app:
|
| 42 |
dir_1=d_app.split("/",1)[0]
|
|
@@ -65,27 +64,7 @@ def show_f(repo,name,token):
|
|
| 65 |
pf=d_app.split(".",1)[0]
|
| 66 |
f_name=f'{pf}.{sf}'
|
| 67 |
pass
|
| 68 |
-
|
| 69 |
-
#numbers = [x for x in images if img in f_name]
|
| 70 |
-
img_tog=False
|
| 71 |
-
for img in images:
|
| 72 |
-
if img in f_name:
|
| 73 |
-
url = f"https://huggingface.co/spaces/{repo}/{name}/resolve/main/{d_app}"
|
| 74 |
-
r = requests.get(url)
|
| 75 |
-
with open(f'{name}/{f_name}', "wb") as f:
|
| 76 |
-
f.write(r.content)
|
| 77 |
-
#html_text += f'<object data="https://huggingface.co/spaces/{repo}/{name}/raw/main/{d_app}"'
|
| 78 |
-
#out_text = "Image File"
|
| 79 |
-
#https://huggingface.co/spaces/Omnibus/idefics_playground/resolve/main/example_images/cat_sketch.png
|
| 80 |
-
#sav_im = Image.open(f"https://huggingface.co/spaces/{repo}/{name}/resolve/main/{d_app}")
|
| 81 |
-
#sav_im.save(f'{name}/{f_name}')
|
| 82 |
-
file_list.append(Path(f'{name}/{f_name}'))
|
| 83 |
-
#file_out.append(f"https://huggingface.co/spaces/{repo}/{name}/raw/main/{d_app}")
|
| 84 |
-
img_tog=True
|
| 85 |
-
else:
|
| 86 |
-
pass
|
| 87 |
-
if img_tog == False:
|
| 88 |
-
'''
|
| 89 |
r = requests.get(f'https://huggingface.co/spaces/{repo}/{name}/raw/main/{d_app}')
|
| 90 |
print(d_app)
|
| 91 |
#print (r.text)
|
|
@@ -137,7 +116,7 @@ def show_f2(repo,name,token):
|
|
| 137 |
|
| 138 |
|
| 139 |
def show_f_cont(repo,name,file,token):
|
| 140 |
-
html_text = '<html>\n<body>\n<div>\n'
|
| 141 |
|
| 142 |
if (".png" or ".jpg" or ".gif" or ".webm" or ".mp4") in file:
|
| 143 |
html_text += f'<object data="https://huggingface.co/spaces/{repo}/{name}/resolve/main/{file}"'
|
|
|
|
| 36 |
#file_out = []
|
| 37 |
if not os.path.exists(name):
|
| 38 |
os.makedirs(name)
|
|
|
|
| 39 |
for d_app in f_ist:
|
| 40 |
if "/" in d_app:
|
| 41 |
dir_1=d_app.split("/",1)[0]
|
|
|
|
| 64 |
pf=d_app.split(".",1)[0]
|
| 65 |
f_name=f'{pf}.{sf}'
|
| 66 |
pass
|
| 67 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
r = requests.get(f'https://huggingface.co/spaces/{repo}/{name}/raw/main/{d_app}')
|
| 69 |
print(d_app)
|
| 70 |
#print (r.text)
|
|
|
|
| 116 |
|
| 117 |
|
| 118 |
def show_f_cont(repo,name,file,token):
|
| 119 |
+
html_text = '<html>\n<body>\n<div id="my_div">\n'
|
| 120 |
|
| 121 |
if (".png" or ".jpg" or ".gif" or ".webm" or ".mp4") in file:
|
| 122 |
html_text += f'<object data="https://huggingface.co/spaces/{repo}/{name}/resolve/main/{file}"'
|