Spaces:
Running
on
Zero
Running
on
Zero
reedmayhew
commited on
Commit
•
80950c2
1
Parent(s):
7129683
Update app.py
Browse files
app.py
CHANGED
@@ -45,7 +45,7 @@ def upscale_chunk(chunk, model, processor, device):
|
|
45 |
return Image.fromarray(output_image)
|
46 |
|
47 |
@spaces.GPU
|
48 |
-
def main(image, model_choice, save_as_jpg=True, use_tiling=True):
|
49 |
# Resize the input image
|
50 |
image = resize_image(image)
|
51 |
|
@@ -79,8 +79,8 @@ def main(image, model_choice, save_as_jpg=True, use_tiling=True):
|
|
79 |
upscaled_image = upscale_chunk(image, model, processor, device)
|
80 |
|
81 |
# Generate output filename
|
82 |
-
|
83 |
-
output_filename = f"{
|
84 |
|
85 |
if save_as_jpg:
|
86 |
output_filename += ".jpg"
|
@@ -93,7 +93,8 @@ def main(image, model_choice, save_as_jpg=True, use_tiling=True):
|
|
93 |
|
94 |
def gradio_interface(image, model_choice, save_as_jpg, use_tiling):
|
95 |
try:
|
96 |
-
|
|
|
97 |
return result, None
|
98 |
except Exception as e:
|
99 |
return None, str(e)
|
|
|
45 |
return Image.fromarray(output_image)
|
46 |
|
47 |
@spaces.GPU
|
48 |
+
def main(image, original_filename, model_choice, save_as_jpg=True, use_tiling=True):
|
49 |
# Resize the input image
|
50 |
image = resize_image(image)
|
51 |
|
|
|
79 |
upscaled_image = upscale_chunk(image, model, processor, device)
|
80 |
|
81 |
# Generate output filename
|
82 |
+
original_basename = os.path.splitext(original_filename)[0] if original_filename else "image"
|
83 |
+
output_filename = f"{original_basename}_upscaled"
|
84 |
|
85 |
if save_as_jpg:
|
86 |
output_filename += ".jpg"
|
|
|
93 |
|
94 |
def gradio_interface(image, model_choice, save_as_jpg, use_tiling):
|
95 |
try:
|
96 |
+
original_filename = getattr(image, 'name', 'image')
|
97 |
+
result = main(image, original_filename, model_choice, save_as_jpg, use_tiling)
|
98 |
return result, None
|
99 |
except Exception as e:
|
100 |
return None, str(e)
|