Spaces:
Running
Running
Update app.py
Browse files
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
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
return
|
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(
|