Update app.py
Browse files
app.py
CHANGED
|
@@ -1,22 +1,11 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
| 2 |
import numpy as np
|
| 3 |
from PIL import Image
|
| 4 |
import tensorflow as tf
|
| 5 |
from transformers import SegformerFeatureExtractor, TFSegformerForSemanticSegmentation
|
| 6 |
-
from matplotlib import gridspec
|
| 7 |
-
import matplotlib.pyplot as plt
|
| 8 |
-
|
| 9 |
-
# TensorFlow 버전 충돌 해결을 위해 2.0 버전 이상을 사용
|
| 10 |
-
if tf.__version__.startswith("1."):
|
| 11 |
-
tf.compat.v1.disable_v2_behavior()
|
| 12 |
-
tf.compat.v1.enable_eager_execution()
|
| 13 |
-
tf.compat.v1.InteractiveSession()
|
| 14 |
-
tf.compat.v1.get_default_graph()
|
| 15 |
-
tf.compat.v1.disable_eager_execution()
|
| 16 |
-
|
| 17 |
-
# 모델 및 특성 추출기 로드
|
| 18 |
-
feature_extractor = SegformerFeatureExtractor.from_pretrained("mattmdjaga/segformer_b2_clothes")
|
| 19 |
-
model = TFSegformerForSemanticSegmentation.from_pretrained("mattmdjaga/segformer_b2_clothes")
|
| 20 |
|
| 21 |
feature_extractor = SegformerFeatureExtractor.from_pretrained(
|
| 22 |
"mattmdjaga/segformer_b2_clothes"
|
|
@@ -112,9 +101,11 @@ def sepia(input_img):
|
|
| 112 |
return fig
|
| 113 |
|
| 114 |
demo = gr.Interface(fn=sepia,
|
| 115 |
-
inputs=gr.Image(),
|
| 116 |
outputs=['plot'],
|
| 117 |
examples=["person-1.jpg", "person-2.jpg", "person-3.jpg", "person-4.jpg", "person-5.jpg"],
|
| 118 |
allow_flagging='never')
|
| 119 |
|
|
|
|
| 120 |
demo.launch()
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
|
| 3 |
+
from matplotlib import gridspec
|
| 4 |
+
import matplotlib.pyplot as plt
|
| 5 |
import numpy as np
|
| 6 |
from PIL import Image
|
| 7 |
import tensorflow as tf
|
| 8 |
from transformers import SegformerFeatureExtractor, TFSegformerForSemanticSegmentation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
feature_extractor = SegformerFeatureExtractor.from_pretrained(
|
| 11 |
"mattmdjaga/segformer_b2_clothes"
|
|
|
|
| 101 |
return fig
|
| 102 |
|
| 103 |
demo = gr.Interface(fn=sepia,
|
| 104 |
+
inputs=gr.Image(shape=(400, 600)),
|
| 105 |
outputs=['plot'],
|
| 106 |
examples=["person-1.jpg", "person-2.jpg", "person-3.jpg", "person-4.jpg", "person-5.jpg"],
|
| 107 |
allow_flagging='never')
|
| 108 |
|
| 109 |
+
|
| 110 |
demo.launch()
|
| 111 |
+
|