Spaces:
Running
on
Zero
Running
on
Zero
Update debug.py
Browse files
debug.py
CHANGED
@@ -29,7 +29,7 @@ scheduler = CommitScheduler(
|
|
29 |
|
30 |
def cache_temp(img_id):
|
31 |
api.upload_file(
|
32 |
-
path_or_fileobj=os.path.join("/tmp/
|
33 |
|
34 |
path_in_repo="/v" + APP_VERSION + "/" + img_id,
|
35 |
repo_id=HF_DATASET_REPO,
|
@@ -44,15 +44,17 @@ def save_image(image_id, image_path: Image.Image) -> None:
|
|
44 |
print("Save image path: " + save_image_path)
|
45 |
try:
|
46 |
loaded = load_image(image_path)
|
|
|
|
|
47 |
print("Loaded Type: " + str(type(loaded)))
|
48 |
with scheduler.lock:
|
49 |
try:
|
50 |
-
cache_temp(
|
51 |
-
|
52 |
-
print("Type: " + str(type(
|
53 |
try:
|
54 |
-
|
55 |
-
|
56 |
|
57 |
print(f"Saved image: {save_image_path}")
|
58 |
except Exception as e:
|
|
|
29 |
|
30 |
def cache_temp(img_id):
|
31 |
api.upload_file(
|
32 |
+
path_or_fileobj=os.path.join("/tmp/gradio", f"{img_id}"),
|
33 |
|
34 |
path_in_repo="/v" + APP_VERSION + "/" + img_id,
|
35 |
repo_id=HF_DATASET_REPO,
|
|
|
44 |
print("Save image path: " + save_image_path)
|
45 |
try:
|
46 |
loaded = load_image(image_path)
|
47 |
+
cache_file = "/tmp/gradio/" + str(uuid.uuid4()) + ".png"
|
48 |
+
loaded.save(cache_file, "PNG")
|
49 |
print("Loaded Type: " + str(type(loaded)))
|
50 |
with scheduler.lock:
|
51 |
try:
|
52 |
+
cache_temp(cache_file)
|
53 |
+
print("Cache path: " + cache_file)
|
54 |
+
print("Type: " + str(type(cache_file)))
|
55 |
try:
|
56 |
+
img2 = Image.open(cache_file)
|
57 |
+
img2.save(save_image_path)
|
58 |
|
59 |
print(f"Saved image: {save_image_path}")
|
60 |
except Exception as e:
|