Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,6 +9,8 @@ import json
|
|
| 9 |
import io
|
| 10 |
|
| 11 |
import torch
|
|
|
|
|
|
|
| 12 |
from safetensors.torch import load_file
|
| 13 |
from huggingface_hub import hf_hub_download
|
| 14 |
|
|
@@ -20,14 +22,10 @@ from diffusers import FluxPipeline
|
|
| 20 |
from google import genai
|
| 21 |
from google.genai import types
|
| 22 |
|
| 23 |
-
# PIL ์ด๋ฏธ์ง ์ฒ๋ฆฌ๋ฅผ ์ํด ์ถ๊ฐ
|
| 24 |
-
from PIL import Image
|
| 25 |
-
|
| 26 |
#######################################
|
| 27 |
# 0. ํ๊ฒฝ์ค์
|
| 28 |
#######################################
|
| 29 |
|
| 30 |
-
# ๋ชจ๋ธ ์บ์ ๋๋ ํ ๋ฆฌ ์ค์
|
| 31 |
BASE_DIR = path.dirname(path.abspath(__file__)) if "__file__" in globals() else os.getcwd()
|
| 32 |
CACHE_PATH = path.join(BASE_DIR, "models")
|
| 33 |
|
|
@@ -35,9 +33,6 @@ os.environ["TRANSFORMERS_CACHE"] = CACHE_PATH
|
|
| 35 |
os.environ["HF_HUB_CACHE"] = CACHE_PATH
|
| 36 |
os.environ["HF_HOME"] = CACHE_PATH
|
| 37 |
|
| 38 |
-
# (์์) Google GenAI ์ฌ์ฉ:
|
| 39 |
-
# export GAPI_TOKEN="<YOUR_GOOGLE_GENAI_API_KEY>"
|
| 40 |
-
|
| 41 |
# ๊ฐ๋จํ ํ์ด๋จธ ํด๋์ค
|
| 42 |
class timer:
|
| 43 |
def __init__(self, method_name="timed process"):
|
|
@@ -56,18 +51,15 @@ class timer:
|
|
| 56 |
if not path.exists(CACHE_PATH):
|
| 57 |
os.makedirs(CACHE_PATH, exist_ok=True)
|
| 58 |
|
| 59 |
-
# FLUX ํ์ดํ๋ผ์ธ ๋ก๋
|
| 60 |
pipe = FluxPipeline.from_pretrained(
|
| 61 |
-
"black-forest-labs/FLUX.1-dev",
|
| 62 |
torch_dtype=torch.bfloat16
|
| 63 |
)
|
| 64 |
|
| 65 |
-
# LoRA ๊ฐ์ค์น ๋ก๋
|
| 66 |
lora_path = hf_hub_download("ByteDance/Hyper-SD", "Hyper-FLUX.1-dev-8steps-lora.safetensors")
|
| 67 |
pipe.load_lora_weights(lora_path)
|
| 68 |
pipe.fuse_lora(lora_scale=0.125)
|
| 69 |
|
| 70 |
-
# GPU๋ก ์ฎ๊ธฐ๊ธฐ
|
| 71 |
pipe.to(device="cuda", dtype=torch.bfloat16)
|
| 72 |
|
| 73 |
#######################################
|
|
@@ -86,7 +78,7 @@ def generate_by_google_genai(text, file_name, model="gemini-2.0-flash-exp"):
|
|
| 86 |
- file_name: ์๋ณธ ์ด๋ฏธ์ง(์: .png) ๊ฒฝ๋ก
|
| 87 |
- model: ์ฌ์ฉํ gemini ๋ชจ๋ธ ์ด๋ฆ
|
| 88 |
"""
|
| 89 |
-
#
|
| 90 |
api_key = os.getenv("GAPI_TOKEN", None)
|
| 91 |
if not api_key:
|
| 92 |
raise ValueError(
|
|
@@ -94,13 +86,12 @@ def generate_by_google_genai(text, file_name, model="gemini-2.0-flash-exp"):
|
|
| 94 |
"Google GenAI API๋ฅผ ์ฌ์ฉํ๊ธฐ ์ํด์๋ GAPI_TOKEN์ด ํ์ํฉ๋๋ค."
|
| 95 |
)
|
| 96 |
|
| 97 |
-
# (2) Google Client ์ด๊ธฐํ
|
| 98 |
client = genai.Client(api_key=api_key)
|
| 99 |
|
| 100 |
-
#
|
| 101 |
files = [client.files.upload(file=file_name)]
|
| 102 |
|
| 103 |
-
#
|
| 104 |
contents = [
|
| 105 |
types.Content(
|
| 106 |
role="user",
|
|
@@ -114,7 +105,6 @@ def generate_by_google_genai(text, file_name, model="gemini-2.0-flash-exp"):
|
|
| 114 |
),
|
| 115 |
]
|
| 116 |
|
| 117 |
-
# (5) ์์ฑ/๋ณํ ์ค์
|
| 118 |
generate_content_config = types.GenerateContentConfig(
|
| 119 |
temperature=1,
|
| 120 |
top_p=0.95,
|
|
@@ -127,10 +117,9 @@ def generate_by_google_genai(text, file_name, model="gemini-2.0-flash-exp"):
|
|
| 127 |
text_response = ""
|
| 128 |
image_path = None
|
| 129 |
|
| 130 |
-
# ์์
|
| 131 |
with tempfile.NamedTemporaryFile(suffix=".png", delete=False) as tmp:
|
| 132 |
temp_path = tmp.name
|
| 133 |
-
# 5) ์คํธ๋ฆผ ํํ๋ก ์๋ต ๋ฐ์์ ์ด๋ฏธ์ง/ํ
์คํธ ๊ตฌ๋ถ ์ฒ๋ฆฌ
|
| 134 |
for chunk in client.models.generate_content_stream(
|
| 135 |
model=model,
|
| 136 |
contents=contents,
|
|
@@ -140,35 +129,32 @@ def generate_by_google_genai(text, file_name, model="gemini-2.0-flash-exp"):
|
|
| 140 |
continue
|
| 141 |
candidate = chunk.candidates[0].content.parts[0]
|
| 142 |
|
| 143 |
-
# inline_data
|
| 144 |
if candidate.inline_data:
|
| 145 |
save_binary_file(temp_path, candidate.inline_data.data)
|
| 146 |
print(f"File of mime type {candidate.inline_data.mime_type} saved to: {temp_path}")
|
| 147 |
image_path = temp_path
|
| 148 |
-
# ์ด๋ฏธ์ง๊ฐ ์์ฑ๋๋ฉด ๋ณดํต ์ฌ๊ธฐ์ break
|
| 149 |
break
|
| 150 |
else:
|
| 151 |
-
# ์ด๋ฏธ์ง ์์ด ํ
์คํธ๋ง ๋ฐํ๋๋ ๊ฒฝ์ฐ(ํฌ๋ฐ) ๋์
|
| 152 |
text_response += chunk.text + "\n"
|
| 153 |
|
| 154 |
-
# ์
๋ก๋ํ File ๊ฐ์ฒด ์ ๊ฑฐ
|
| 155 |
del files
|
| 156 |
-
|
| 157 |
return image_path, text_response
|
| 158 |
|
| 159 |
#######################################
|
| 160 |
-
# 3. Gradio
|
| 161 |
-
# (1) FLUX๋ก ์ด๋ฏธ์ง ์์ฑ ->
|
| 162 |
-
# (2) Google GenAI๋ก ํ
์คํธ ๊ต์ฒด
|
| 163 |
#######################################
|
| 164 |
|
| 165 |
def generate_initial_image(prompt, text, height, width, steps, scale, seed):
|
| 166 |
"""
|
| 167 |
-
FLUX
|
| 168 |
-
prompt
|
| 169 |
-
|
| 170 |
"""
|
| 171 |
-
|
|
|
|
|
|
|
|
|
|
| 172 |
|
| 173 |
with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16), timer("inference"):
|
| 174 |
result = pipe(
|
|
@@ -185,70 +171,70 @@ def generate_initial_image(prompt, text, height, width, steps, scale, seed):
|
|
| 185 |
|
| 186 |
def change_text_in_image(original_image, new_text):
|
| 187 |
"""
|
| 188 |
-
|
| 189 |
์
๋ก๋๋ ์ด๋ฏธ์ง ๋ด๋ถ์ ๋ฌธ๊ตฌ๋ฅผ `new_text`๋ก ๋ณ๊ฒฝํด์ฃผ๋ ํจ์.
|
| 190 |
"""
|
| 191 |
try:
|
| 192 |
-
#
|
| 193 |
with tempfile.NamedTemporaryFile(suffix=".png", delete=False) as tmp:
|
| 194 |
original_path = tmp.name
|
| 195 |
original_image.save(original_path)
|
| 196 |
|
| 197 |
-
# Gemini ๋ชจ๋ธ
|
| 198 |
image_path, text_response = generate_by_google_genai(
|
| 199 |
text=f"Change the text in this image to: '{new_text}'",
|
| 200 |
file_name=original_path
|
| 201 |
)
|
| 202 |
|
| 203 |
-
# ๊ฒฐ๊ณผ๊ฐ ์ด๋ฏธ์ง๋ก ๋ฐํ๋ ๊ฒฝ์ฐ
|
| 204 |
if image_path:
|
| 205 |
-
# Gradio
|
| 206 |
with open(image_path, "rb") as f:
|
| 207 |
image_data = f.read()
|
| 208 |
-
|
| 209 |
-
# base64๋ฅผ ๊ฑฐ์น์ง ์๊ณ , PIL Image๋ก ๋์ฝ๋ฉ
|
| 210 |
modified_img = Image.open(io.BytesIO(image_data))
|
| 211 |
return modified_img, ""
|
| 212 |
-
|
| 213 |
else:
|
| 214 |
-
# ์ด๋ฏธ์ง ์์ด ํ
์คํธ๋ง ์๋ต์ผ๋ก ์จ ๊ฒฝ์ฐ
|
| 215 |
return None, text_response
|
| 216 |
|
| 217 |
except Exception as e:
|
| 218 |
raise gr.Error(f"Error: {e}")
|
| 219 |
|
| 220 |
-
|
| 221 |
#######################################
|
| 222 |
-
# 4. Gradio ์ธํฐํ์ด์ค
|
| 223 |
#######################################
|
| 224 |
|
| 225 |
with gr.Blocks(title="Flux + Google GenAI Text Replacement") as demo:
|
| 226 |
gr.Markdown(
|
| 227 |
"""
|
| 228 |
-
# Flux
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
---
|
| 235 |
"""
|
| 236 |
)
|
| 237 |
|
| 238 |
with gr.Row():
|
| 239 |
with gr.Column():
|
| 240 |
-
gr.Markdown("## 1)
|
| 241 |
prompt_input = gr.Textbox(
|
| 242 |
lines=3,
|
| 243 |
-
label="
|
| 244 |
-
placeholder="
|
| 245 |
)
|
| 246 |
text_input = gr.Textbox(
|
| 247 |
lines=1,
|
| 248 |
-
label="
|
| 249 |
-
placeholder="
|
| 250 |
)
|
| 251 |
-
with gr.Accordion("
|
| 252 |
height = gr.Slider(label="Height", minimum=256, maximum=1152, step=64, value=512)
|
| 253 |
width = gr.Slider(label="Width", minimum=256, maximum=1152, step=64, value=512)
|
| 254 |
steps = gr.Slider(label="Inference Steps", minimum=6, maximum=25, step=1, value=8)
|
|
@@ -256,18 +242,13 @@ with gr.Blocks(title="Flux + Google GenAI Text Replacement") as demo:
|
|
| 256 |
seed = gr.Number(label="Seed (reproducibility)", value=1234, precision=0)
|
| 257 |
|
| 258 |
generate_btn = gr.Button("Generate Base Image", variant="primary")
|
| 259 |
-
|
| 260 |
-
# ์์ฑ ๊ฒฐ๊ณผ ํ์
|
| 261 |
-
generated_image = gr.Image(
|
| 262 |
-
label="Generated Image (with text)",
|
| 263 |
-
type="pil"
|
| 264 |
-
)
|
| 265 |
|
| 266 |
with gr.Column():
|
| 267 |
-
gr.Markdown("## 2)
|
| 268 |
new_text_input = gr.Textbox(
|
| 269 |
-
label="
|
| 270 |
-
placeholder="
|
| 271 |
)
|
| 272 |
modify_btn = gr.Button("Change Text in Image via Gemini", variant="secondary")
|
| 273 |
output_img = gr.Image(label="Modified Image", type="pil")
|
|
@@ -286,5 +267,4 @@ with gr.Blocks(title="Flux + Google GenAI Text Replacement") as demo:
|
|
| 286 |
outputs=[output_img, output_txt]
|
| 287 |
)
|
| 288 |
|
| 289 |
-
# Gradio ์คํ
|
| 290 |
demo.launch(max_threads=20)
|
|
|
|
| 9 |
import io
|
| 10 |
|
| 11 |
import torch
|
| 12 |
+
from PIL import Image
|
| 13 |
+
|
| 14 |
from safetensors.torch import load_file
|
| 15 |
from huggingface_hub import hf_hub_download
|
| 16 |
|
|
|
|
| 22 |
from google import genai
|
| 23 |
from google.genai import types
|
| 24 |
|
|
|
|
|
|
|
|
|
|
| 25 |
#######################################
|
| 26 |
# 0. ํ๊ฒฝ์ค์
|
| 27 |
#######################################
|
| 28 |
|
|
|
|
| 29 |
BASE_DIR = path.dirname(path.abspath(__file__)) if "__file__" in globals() else os.getcwd()
|
| 30 |
CACHE_PATH = path.join(BASE_DIR, "models")
|
| 31 |
|
|
|
|
| 33 |
os.environ["HF_HUB_CACHE"] = CACHE_PATH
|
| 34 |
os.environ["HF_HOME"] = CACHE_PATH
|
| 35 |
|
|
|
|
|
|
|
|
|
|
| 36 |
# ๊ฐ๋จํ ํ์ด๋จธ ํด๋์ค
|
| 37 |
class timer:
|
| 38 |
def __init__(self, method_name="timed process"):
|
|
|
|
| 51 |
if not path.exists(CACHE_PATH):
|
| 52 |
os.makedirs(CACHE_PATH, exist_ok=True)
|
| 53 |
|
|
|
|
| 54 |
pipe = FluxPipeline.from_pretrained(
|
| 55 |
+
"black-forest-labs/FLUX.1-dev",
|
| 56 |
torch_dtype=torch.bfloat16
|
| 57 |
)
|
| 58 |
|
|
|
|
| 59 |
lora_path = hf_hub_download("ByteDance/Hyper-SD", "Hyper-FLUX.1-dev-8steps-lora.safetensors")
|
| 60 |
pipe.load_lora_weights(lora_path)
|
| 61 |
pipe.fuse_lora(lora_scale=0.125)
|
| 62 |
|
|
|
|
| 63 |
pipe.to(device="cuda", dtype=torch.bfloat16)
|
| 64 |
|
| 65 |
#######################################
|
|
|
|
| 78 |
- file_name: ์๋ณธ ์ด๋ฏธ์ง(์: .png) ๊ฒฝ๋ก
|
| 79 |
- model: ์ฌ์ฉํ gemini ๋ชจ๋ธ ์ด๋ฆ
|
| 80 |
"""
|
| 81 |
+
# GAPI_TOKEN ํ๊ฒฝ๋ณ์์์ ํค๋ฅผ ๊ฐ์ ธ์ด (ํ์)
|
| 82 |
api_key = os.getenv("GAPI_TOKEN", None)
|
| 83 |
if not api_key:
|
| 84 |
raise ValueError(
|
|
|
|
| 86 |
"Google GenAI API๋ฅผ ์ฌ์ฉํ๊ธฐ ์ํด์๋ GAPI_TOKEN์ด ํ์ํฉ๋๋ค."
|
| 87 |
)
|
| 88 |
|
|
|
|
| 89 |
client = genai.Client(api_key=api_key)
|
| 90 |
|
| 91 |
+
# ์ด๋ฏธ์ง ์
๋ก๋
|
| 92 |
files = [client.files.upload(file=file_name)]
|
| 93 |
|
| 94 |
+
# gemini์ ์ ๋ฌํ Content ์ค๋น
|
| 95 |
contents = [
|
| 96 |
types.Content(
|
| 97 |
role="user",
|
|
|
|
| 105 |
),
|
| 106 |
]
|
| 107 |
|
|
|
|
| 108 |
generate_content_config = types.GenerateContentConfig(
|
| 109 |
temperature=1,
|
| 110 |
top_p=0.95,
|
|
|
|
| 117 |
text_response = ""
|
| 118 |
image_path = None
|
| 119 |
|
| 120 |
+
# ์์ ํ์ผ์ ์ด๋ฏธ์ง ์๋ต์ ์ ์ฅํ ์ค๋น
|
| 121 |
with tempfile.NamedTemporaryFile(suffix=".png", delete=False) as tmp:
|
| 122 |
temp_path = tmp.name
|
|
|
|
| 123 |
for chunk in client.models.generate_content_stream(
|
| 124 |
model=model,
|
| 125 |
contents=contents,
|
|
|
|
| 129 |
continue
|
| 130 |
candidate = chunk.candidates[0].content.parts[0]
|
| 131 |
|
| 132 |
+
# inline_data(์ด๋ฏธ์ง) ์๋ต์ธ ๊ฒฝ์ฐ
|
| 133 |
if candidate.inline_data:
|
| 134 |
save_binary_file(temp_path, candidate.inline_data.data)
|
| 135 |
print(f"File of mime type {candidate.inline_data.mime_type} saved to: {temp_path}")
|
| 136 |
image_path = temp_path
|
|
|
|
| 137 |
break
|
| 138 |
else:
|
|
|
|
| 139 |
text_response += chunk.text + "\n"
|
| 140 |
|
|
|
|
| 141 |
del files
|
|
|
|
| 142 |
return image_path, text_response
|
| 143 |
|
| 144 |
#######################################
|
| 145 |
+
# 3. Gradio ํจ์
|
|
|
|
|
|
|
| 146 |
#######################################
|
| 147 |
|
| 148 |
def generate_initial_image(prompt, text, height, width, steps, scale, seed):
|
| 149 |
"""
|
| 150 |
+
FLUX๋ฅผ ์ด์ฉํด ํ
์คํธ๊ฐ ํฌํจ๋ ์ด๋ฏธ์ง๋ฅผ ์์ฑ
|
| 151 |
+
- prompt ๋ด์ <text>๋ผ๋ ํน์ ๊ตฌ๋ถ์๊ฐ ์์ผ๋ฉด, ๊ฑฐ๊ธฐ์ text๊ฐ ์นํ๋จ.
|
| 152 |
+
- ๊ทธ๋ ์ง ์์ ๊ฒฝ์ฐ, ๊ธฐ์กด์ฒ๋ผ prompt ๋ค์ โwith clear readable text that says ...โ๏ฟฝ๏ฟฝ ์ถ๊ฐ.
|
| 153 |
"""
|
| 154 |
+
if "<text>" in prompt:
|
| 155 |
+
combined_prompt = prompt.replace("<text>", text)
|
| 156 |
+
else:
|
| 157 |
+
combined_prompt = f"{prompt} with clear readable text that says '{text}'"
|
| 158 |
|
| 159 |
with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16), timer("inference"):
|
| 160 |
result = pipe(
|
|
|
|
| 171 |
|
| 172 |
def change_text_in_image(original_image, new_text):
|
| 173 |
"""
|
| 174 |
+
Gemini ๋ชจ๋ธ์ ํตํด,
|
| 175 |
์
๋ก๋๋ ์ด๋ฏธ์ง ๋ด๋ถ์ ๋ฌธ๊ตฌ๋ฅผ `new_text`๋ก ๋ณ๊ฒฝํด์ฃผ๋ ํจ์.
|
| 176 |
"""
|
| 177 |
try:
|
| 178 |
+
# ์์ ํ์ผ์ ๋จผ์ ์ ์ฅ
|
| 179 |
with tempfile.NamedTemporaryFile(suffix=".png", delete=False) as tmp:
|
| 180 |
original_path = tmp.name
|
| 181 |
original_image.save(original_path)
|
| 182 |
|
| 183 |
+
# Gemini ๋ชจ๋ธ ํธ์ถ
|
| 184 |
image_path, text_response = generate_by_google_genai(
|
| 185 |
text=f"Change the text in this image to: '{new_text}'",
|
| 186 |
file_name=original_path
|
| 187 |
)
|
| 188 |
|
|
|
|
| 189 |
if image_path:
|
| 190 |
+
# Gradio ๊ตฌ๋ฒ์ ์๋ decode_base64_to_image๊ฐ ์์ผ๋ฏ๋ก PIL์ ์ง์ ์ฌ์ฉ
|
| 191 |
with open(image_path, "rb") as f:
|
| 192 |
image_data = f.read()
|
|
|
|
|
|
|
| 193 |
modified_img = Image.open(io.BytesIO(image_data))
|
| 194 |
return modified_img, ""
|
|
|
|
| 195 |
else:
|
|
|
|
| 196 |
return None, text_response
|
| 197 |
|
| 198 |
except Exception as e:
|
| 199 |
raise gr.Error(f"Error: {e}")
|
| 200 |
|
|
|
|
| 201 |
#######################################
|
| 202 |
+
# 4. Gradio ์ธํฐํ์ด์ค
|
| 203 |
#######################################
|
| 204 |
|
| 205 |
with gr.Blocks(title="Flux + Google GenAI Text Replacement") as demo:
|
| 206 |
gr.Markdown(
|
| 207 |
"""
|
| 208 |
+
# Flux Image Generation + Google GenAI Text Replacement
|
| 209 |
+
|
| 210 |
+
**Usage Instructions (in English)**
|
| 211 |
+
1. Write a prompt that may contain the special placeholder `<text>`.
|
| 212 |
+
- Example: `A white cat says <text> in a cartoon style`.
|
| 213 |
+
2. Enter the actual text in the "Text to Include in the Image" field.
|
| 214 |
+
- Example: `์๋
`
|
| 215 |
+
3. Click the "Generate Base Image" button.
|
| 216 |
+
- The prompt will be transformed so that `<text>` is replaced with your actual text.
|
| 217 |
+
- If `<text>` is **not** found, the text will be appended automatically as `with clear readable text that says ...`.
|
| 218 |
+
4. (Optional) If you want to change the text again, use the "Change Text in Image" button.
|
| 219 |
+
|
| 220 |
---
|
| 221 |
"""
|
| 222 |
)
|
| 223 |
|
| 224 |
with gr.Row():
|
| 225 |
with gr.Column():
|
| 226 |
+
gr.Markdown("## 1) Generate the Base Image (FLUX)")
|
| 227 |
prompt_input = gr.Textbox(
|
| 228 |
lines=3,
|
| 229 |
+
label="Prompt (with optional `<text>` placeholder)",
|
| 230 |
+
placeholder="e.g. A white cat says <text> in a cartoon style"
|
| 231 |
)
|
| 232 |
text_input = gr.Textbox(
|
| 233 |
lines=1,
|
| 234 |
+
label="Text to Include in the Image",
|
| 235 |
+
placeholder="e.g. ์๋
"
|
| 236 |
)
|
| 237 |
+
with gr.Accordion("Advanced Settings", open=False):
|
| 238 |
height = gr.Slider(label="Height", minimum=256, maximum=1152, step=64, value=512)
|
| 239 |
width = gr.Slider(label="Width", minimum=256, maximum=1152, step=64, value=512)
|
| 240 |
steps = gr.Slider(label="Inference Steps", minimum=6, maximum=25, step=1, value=8)
|
|
|
|
| 242 |
seed = gr.Number(label="Seed (reproducibility)", value=1234, precision=0)
|
| 243 |
|
| 244 |
generate_btn = gr.Button("Generate Base Image", variant="primary")
|
| 245 |
+
generated_image = gr.Image(label="Generated Image", type="pil")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 246 |
|
| 247 |
with gr.Column():
|
| 248 |
+
gr.Markdown("## 2) (Optional) Change Text in the Generated Image (Gemini)")
|
| 249 |
new_text_input = gr.Textbox(
|
| 250 |
+
label="New Text to Insert",
|
| 251 |
+
placeholder="e.g. Hello"
|
| 252 |
)
|
| 253 |
modify_btn = gr.Button("Change Text in Image via Gemini", variant="secondary")
|
| 254 |
output_img = gr.Image(label="Modified Image", type="pil")
|
|
|
|
| 267 |
outputs=[output_img, output_txt]
|
| 268 |
)
|
| 269 |
|
|
|
|
| 270 |
demo.launch(max_threads=20)
|