Kims12 commited on
Commit
3550322
ยท
verified ยท
1 Parent(s): 2b13f4e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -1,7 +1,6 @@
1
  import gradio as gr
2
  from gradio_imageslider import ImageSlider
3
  from loadimg import load_img
4
- import spaces
5
  from transformers import AutoModelForImageSegmentation
6
  import torch
7
  from torchvision import transforms
@@ -49,13 +48,13 @@ def fn(image):
49
 
50
  return [processed_image], jpg_path # ImageSlider๋Š” ๋ฆฌ์ŠคํŠธ๋ฅผ ๊ธฐ๋Œ€ํ•จ
51
 
52
- def process_file(f):
53
- name_path = f.rsplit(".", 1)[0] + ".png"
54
- im = load_img(f, output_type="pil")
55
- im = im.convert("RGB")
56
- transparent = process(im)
57
- transparent.save(name_path)
58
- return name_path
59
 
60
  # Gradio ์ปดํฌ๋„ŒํŠธ ์ •์˜
61
  slider1 = ImageSlider(label="Processed Image", type="pil")
@@ -63,7 +62,7 @@ image_upload = gr.Image(label="Upload an image")
63
  output_download = gr.File(label="Download JPG File")
64
 
65
  # ์ƒˆ๋กœ์šด ์ƒ˜ํ”Œ ์ด๋ฏธ์ง€ ์ถ”๊ฐ€ (app.py์™€ ๋™์ผํ•œ ํด๋”์— ์œ„์น˜ํ•ด์•ผ ํ•จ)
66
- sample_images = ["1.png", "2.jpg", "3.png"]
67
 
68
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์„ค์ •
69
  tab1 = gr.Interface(
 
1
  import gradio as gr
2
  from gradio_imageslider import ImageSlider
3
  from loadimg import load_img
 
4
  from transformers import AutoModelForImageSegmentation
5
  import torch
6
  from torchvision import transforms
 
48
 
49
  return [processed_image], jpg_path # ImageSlider๋Š” ๋ฆฌ์ŠคํŠธ๋ฅผ ๊ธฐ๋Œ€ํ•จ
50
 
51
+ def convert_to_jpg(image):
52
+ if image is None:
53
+ return None
54
+ jpg_image = image.convert("RGB")
55
+ jpg_path = "downloaded_output.jpg"
56
+ jpg_image.save(jpg_path, format="JPEG")
57
+ return jpg_path
58
 
59
  # Gradio ์ปดํฌ๋„ŒํŠธ ์ •์˜
60
  slider1 = ImageSlider(label="Processed Image", type="pil")
 
62
  output_download = gr.File(label="Download JPG File")
63
 
64
  # ์ƒˆ๋กœ์šด ์ƒ˜ํ”Œ ์ด๋ฏธ์ง€ ์ถ”๊ฐ€ (app.py์™€ ๋™์ผํ•œ ํด๋”์— ์œ„์น˜ํ•ด์•ผ ํ•จ)
65
+ sample_images = [["1.png"], ["2.jpg"], ["3.png"]]
66
 
67
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์„ค์ •
68
  tab1 = gr.Interface(