Spaces:
Sleeping
Sleeping
add image save
Browse files- app.py +9 -1
- demo_header.html +1 -6
app.py
CHANGED
|
@@ -94,6 +94,13 @@ def process_create_gif(images,duration=100, quantize=False,disposal=1,blend=0,lo
|
|
| 94 |
|
| 95 |
return output_buffer.getvalue()
|
| 96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
def convert_webp_to_images(webp_path):
|
| 98 |
# 各フレームをリストに保存
|
| 99 |
frames = []
|
|
@@ -170,7 +177,8 @@ def process_images(input_path,same_size=False,image_width=128,file_format="webp"
|
|
| 170 |
images.append((gif_path,"gif"))
|
| 171 |
else:
|
| 172 |
for i ,frame in enumerate(new_frames):
|
| 173 |
-
|
|
|
|
| 174 |
|
| 175 |
return images
|
| 176 |
|
|
|
|
| 94 |
|
| 95 |
return output_buffer.getvalue()
|
| 96 |
|
| 97 |
+
def save_to_image(image,extension="png"):
|
| 98 |
+
id = get_image_id(image)
|
| 99 |
+
path = os.path.join(dir_name,f"{id}.{extension}")
|
| 100 |
+
image.save(path)
|
| 101 |
+
return path
|
| 102 |
+
|
| 103 |
+
|
| 104 |
def convert_webp_to_images(webp_path):
|
| 105 |
# 各フレームをリストに保存
|
| 106 |
frames = []
|
|
|
|
| 177 |
images.append((gif_path,"gif"))
|
| 178 |
else:
|
| 179 |
for i ,frame in enumerate(new_frames):
|
| 180 |
+
path = save_to_image(frame)
|
| 181 |
+
images.append((path,f"index {i}"))
|
| 182 |
|
| 183 |
return images
|
| 184 |
|
demo_header.html
CHANGED
|
@@ -2,17 +2,12 @@
|
|
| 2 |
<h1>
|
| 3 |
WebP Resize and Convert
|
| 4 |
</h1>
|
| 5 |
-
|
| 6 |
<div class="grid-container">
|
| 7 |
<img src="/gradio_api/file=examples/anime.webp" alt="Flux.1-schnell-WebP3Frame-TalkingAnimation" class="image">
|
| 8 |
<p class="text">
|
| 9 |
Hint:Aspect ratio will always keep<br>
|
| 10 |
I'm not familiar with apng/gif,maybe quality is low<br>
|
|
|
|
| 11 |
</p>
|
| 12 |
</div>
|
| 13 |
-
|
| 14 |
-
<p>
|
| 15 |
-
|
| 16 |
-
</p>
|
| 17 |
-
|
| 18 |
</div>
|
|
|
|
| 2 |
<h1>
|
| 3 |
WebP Resize and Convert
|
| 4 |
</h1>
|
|
|
|
| 5 |
<div class="grid-container">
|
| 6 |
<img src="/gradio_api/file=examples/anime.webp" alt="Flux.1-schnell-WebP3Frame-TalkingAnimation" class="image">
|
| 7 |
<p class="text">
|
| 8 |
Hint:Aspect ratio will always keep<br>
|
| 9 |
I'm not familiar with apng/gif,maybe quality is low<br>
|
| 10 |
+
you can upload apng and gif but not well tested.<br>
|
| 11 |
</p>
|
| 12 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
</div>
|