NightRaven109 commited on
Commit
295f2f9
·
verified ·
1 Parent(s): dc20a3c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -1
app.py CHANGED
@@ -278,7 +278,29 @@ with gr.Blocks(title="Texture Super-Resolution") as demo:
278
  submit_btn = gr.Button("Submit", variant="primary")
279
 
280
  with gr.Column():
281
- output_image = gr.Image(label="Generated Image", type="pil", format="png")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
282
 
283
  # Add examples
284
  gr.Examples(
@@ -328,5 +350,12 @@ with gr.Blocks(title="Texture Super-Resolution") as demo:
328
  ]
329
  )
330
 
 
 
 
 
 
 
 
331
  if __name__ == "__main__":
332
  demo.launch()
 
278
  submit_btn = gr.Button("Submit", variant="primary")
279
 
280
  with gr.Column():
281
+ def custom_save_image(image):
282
+ """Custom save function to ensure maximum PNG quality"""
283
+ if isinstance(image, Image.Image):
284
+ import io
285
+ buffer = io.BytesIO()
286
+ image.save(
287
+ buffer,
288
+ format='PNG',
289
+ optimize=False,
290
+ quality=100,
291
+ subsampling=0
292
+ )
293
+ buffer.seek(0)
294
+ return buffer
295
+
296
+ output_image = gr.Image(
297
+ label="Generated Image",
298
+ type="pil",
299
+ format="png",
300
+ elem_id="output_texture",
301
+ tool="custom-download",
302
+ download_fn=custom_save_image
303
+ )
304
 
305
  # Add examples
306
  gr.Examples(
 
350
  ]
351
  )
352
 
353
+ demo.config = gr.Config(
354
+ png_quality=100,
355
+ png_compression=0,
356
+ file_types=["png"],
357
+ default_enabled_tools=["download"]
358
+ )
359
+
360
  if __name__ == "__main__":
361
  demo.launch()