Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,7 @@
|
|
| 1 |
import os
|
| 2 |
-
import copy
|
| 3 |
import base64
|
| 4 |
import requests
|
| 5 |
import tempfile
|
| 6 |
-
import secrets
|
| 7 |
import gradio as gr
|
| 8 |
from huggingface_hub import upload_file, InferenceClient
|
| 9 |
from PIL import Image
|
|
@@ -25,11 +23,11 @@ def save_and_upload_image(image_b64):
|
|
| 25 |
"""Save image to /tmp and upload to HF dataset."""
|
| 26 |
image_bytes = base64.b64decode(image_b64)
|
| 27 |
# Use a unique filename to prevent conflicts in /tmp
|
| 28 |
-
local_tmp_path = f"/tmp/
|
| 29 |
with open(local_tmp_path, "wb") as f:
|
| 30 |
f.write(image_bytes)
|
| 31 |
|
| 32 |
-
path_in_repo = f"images/
|
| 33 |
upload_file(
|
| 34 |
path_or_fileobj=local_tmp_path,
|
| 35 |
path_in_repo=path_in_repo,
|
|
|
|
| 1 |
import os
|
|
|
|
| 2 |
import base64
|
| 3 |
import requests
|
| 4 |
import tempfile
|
|
|
|
| 5 |
import gradio as gr
|
| 6 |
from huggingface_hub import upload_file, InferenceClient
|
| 7 |
from PIL import Image
|
|
|
|
| 23 |
"""Save image to /tmp and upload to HF dataset."""
|
| 24 |
image_bytes = base64.b64decode(image_b64)
|
| 25 |
# Use a unique filename to prevent conflicts in /tmp
|
| 26 |
+
local_tmp_path = f"/tmp/tmp.jpg"
|
| 27 |
with open(local_tmp_path, "wb") as f:
|
| 28 |
f.write(image_bytes)
|
| 29 |
|
| 30 |
+
path_in_repo = f"images/tmp.jpg"
|
| 31 |
upload_file(
|
| 32 |
path_or_fileobj=local_tmp_path,
|
| 33 |
path_in_repo=path_in_repo,
|