File size: 15,974 Bytes
8b54b39 0117982 49a0c68 9712408 82d8148 68621b1 8864b73 4703cb6 9712408 70d5740 4c38778 1d6da4d 4c38778 9712408 49a0c68 d7402c9 4c38778 175970e 4c38778 175970e 4c38778 0117982 9902612 0117982 64e8dee 82d8148 9712408 64e8dee 46f1c11 64e8dee 82d8148 e75fa96 bcd922b 64e8dee bcd922b e75fa96 b7c3fa1 6339928 75aa8ae 4c6fc6d 64e8dee e75fa96 64e8dee e75fa96 3b8c72d 68621b1 0117982 dcdf3a6 9d292a7 0117982 9712408 0117982 fede236 9712408 fede236 0117982 5e1c057 9225d17 f3b467e 3c2e636 0117982 f3b467e 3c2e636 0117982 9712408 8864b73 dd215db 11b5ad5 9bbee5e d7402c9 9bbee5e d7402c9 9bbee5e dd215db 82d8148 9bbee5e 11b5ad5 8864b73 d7402c9 6339928 814d2de 6339928 9712408 b033337 9712408 6339928 b7a49b1 5e1c057 9bbee5e 9712408 cbdce98 0c3b337 9712408 e3e5ad6 70d5740 9712408 efe039f 70d5740 63f046f 5e1c057 70d5740 efe039f 70d5740 236b356 9712408 b7a49b1 0117982 82d8148 5e1c057 82d8148 9637c92 b033337 68621b1 6339928 5e1c057 236b356 82d8148 4c38778 236b356 2b699d9 ad4d1d5 9d85df9 e33e29b 9712408 d83c511 9d85df9 79e9511 5e7154f 2694e32 a3bfbb2 2694e32 2b699d9 2694e32 16522e7 49024d7 2b699d9 16522e7 0117982 3b8c72d 8bfddb2 0117982 6b33327 bcd922b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 | import os
import openai
import gradio as gr
from diffusers import StableDiffusionPipeline, EulerDiscreteScheduler
import torch
import json
import random
from rembg import remove
from PIL import Image, ImageDraw, ImageFont
import textwrap3 as textwrap
import datetime
from pydrive2.auth import GoogleAuth
from pydrive2.drive import GoogleDrive
from oauth2client.service_account import ServiceAccountCredentials
import base64
from io import BytesIO
css_code = """
body {
overflow: auto !important;
-webkit-overflow-scrolling: touch;
}
"""
def _sanitize_omp_env(default_threads: int = 2):
val = os.environ.get("OMP_NUM_THREADS")
try:
n = int(val) if val is not None else default_threads
if n <= 0:
n = default_threads
os.environ["OMP_NUM_THREADS"] = str(n)
except Exception:
os.environ["OMP_NUM_THREADS"] = str(default_threads)
def create_drive_service(service_account_json_path):
"""
service_account_json_path: ์๋น์ค ๊ณ์ ํค ํ์ผ ๊ฒฝ๋ก
return: pydrive2.drive.GoogleDrive ๊ฐ์ฒด
"""
gauth = GoogleAuth()
# ์๋ SCOPES๋ ํ์ผ ์
๋ก๋/์์ฑ์ ์ํด ํ์ํ Drive ๊ถํ
scope = ['https://www.googleapis.com/auth/drive']
credentials = ServiceAccountCredentials.from_json_keyfile_name(
service_account_json_path, scopes=scope
)
gauth.auth_method = 'service' # ์๋น์ค ๊ณ์ ๋ฐฉ์ ๋ช
์
gauth.credentials = credentials
gauth.ServiceAuth() # ์ด ๋ถ๋ถ์ด ๋งค์ฐ
drive = GoogleDrive(gauth)
return drive
def upload_file_to_drive(drive, folder_id, local_path, new_title):
"""
drive: GoogleDrive ๊ฐ์ฒด
folder_id: ์
๋ก๋ํ ๋์ ํด๋ ID
local_path: ๋ก์ปฌ(๋๋ HF Space) ์์ ์ ์ฅ๋ ํ์ผ ๊ฒฝ๋ก
new_title: ๊ตฌ๊ธ ๋๋ผ์ด๋ธ์ ์ ์ฅ๋ ํ์ผ๋ช
"""
file = drive.CreateFile({
"parents": [{"id": folder_id}],
"title": new_title
})
file.SetContentFile(local_path)
file.Upload()
print(f"Uploaded file '{new_title}' to folder ID={folder_id}.")
# ์ค์ ๊ฒฝ๋ก(ํน์ Secrets)๋ก ๊ต์ฒด
SERVICE_ACCOUNT_JSON = "teeniefinal-448618-35f1b992d016.json"
# ์ ํ์ผ์ Hugging Face "Repository secrets"๋ "Dataset" ๋ฑ์ผ๋ก๋ถํฐ ์ ๊ทผํ ์๋ ์์.
# ํด๋ ID (1fJf44GaNma1A6HYip5Plgo5kX0dN9Rnw)
DRIVE_FOLDER_ID = "16Gd9K0ksZZL1hBpitYWu30Y_ZCtKLXx-"
# ์ธ์ฆ ๊ฐ์ฒด ์์ฑ
drive = create_drive_service(SERVICE_ACCOUNT_JSON)
# OpenAI API ํค ์ค์
client = openai.Client(api_key=os.getenv("OPENAI_API_KEY"))
# ---------------------------
# GPU ๋ชจ๋๋ก ๋ณ๊ฒฝ๋ ๋ถ๋ถ
# ---------------------------
base_model_id = "runwayml/stable-diffusion-v1-5"
# GPU ํ๊ฒฝ์ฉ: torch_dtype=float16, revision='fp16'(ํด๋น ๋ชจ๋ธ์ด ์ง์ํ๋ฉด)
pipe = StableDiffusionPipeline.from_pretrained(
base_model_id,
torch_dtype=torch.float16
).to("cuda") # GPU๋ก ์ด๋
pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config)
def load_lora_weights(pipeline, lora_model_path):
config = {
"lora_r": 16,
"lora_alpha": 32,
"lora_dropout": 0.1,
"bias": "none",
"task_type": "TEXT_TO_IMAGE"
}
pipeline.load_lora_weights(lora_model_path, config=config)
print("LoRA weights successfully loaded!")
lora_model_path = "./TeenieFinal.safetensors"
load_lora_weights(pipe, lora_model_path)
# xformers๋ก ๋ฉ๋ชจ๋ฆฌ ํจ์จ ๊ฐ์ (Spaces์์ xformers๊ฐ ์ค์น๋์ด ์๋ค๋ฉด ์ฌ์ฉ)
try:
pipe.enable_xformers_memory_efficient_attention()
print("Enabled xformers memory efficient attention.")
except Exception as e:
print("Could not enable xformers:", e)
# ์ด๋ฏธ enable_sequential_cpu_offload() ๋ฑ์ CPU ์ต์ ํ ์ด๋ฏ๋ก ์ ๊ฑฐ
# attention_slicing์ GPU์์๋ ๊ฐ๋ฅํ์ง๋ง, ์ผ๋ฐ์ ์ผ๋ก xformers ์ด๋ค๋ฉด ์์ด๋ ๋ฌด๋ฐฉ
pipe.enable_attention_slicing("auto")
def string_to_jsonl(input_string, output_file):
# String ๋ฐ์ดํฐ๋ฅผ ํ์ฑ ๊ฐ๋ฅํ ํํ๋ก ๊ฐ์ (JSON ๋ฐฐ์ด ํ์์ด์ด์ผ ํจ)
try:
data = json.loads(input_string) # JSON ๋ฌธ์์ด ํ์ฑ
if not isinstance(data, list):
raise ValueError("์
๋ ฅ๋ ๋ฌธ์์ด์ด JSON ๋ฐฐ์ด์ด ์๋๋๋ค. JSON ๋ฐฐ์ด๋ก ๋ณํํด์ผ ํฉ๋๋ค.")
# .jsonl ํ์ผ๋ก ์ ์ฅ
with open(output_file, 'w', encoding='utf-8') as file:
for item in data:
file.write(json.dumps(item, ensure_ascii=False) + '\n')
print(f"JSONL ํ์ผ๋ก ๋ณํ ์๋ฃ: {output_file}")
except json.JSONDecodeError:
print("์
๋ ฅ ๋ฌธ์์ด์ด ์ ํจํ JSON ํ์์ด ์๋๋๋ค.")
except Exception as e:
print(f"์ค๋ฅ ๋ฐ์: {e}")
# API ํธ์ถ ํจ์ ์ ์
def generate_response(user_prompt):
try:
# ChatCompletion ์๋ํฌ์ธํธ ์ฌ์ฉ
response = client.chat.completions.create(
model="ft:gpt-4o-2024-08-06:personal:teeniefinal:AsSoCk9F", # fine-tuned ๋ชจ๋ธ ID
messages=[
{"role": "system", "content": (
"๋๋ ์๋ ์บ๋ฆญํฐ๋ฅผ ๊ธฐํํ๋๋ฐ ์ผ๊ฐ๊ฒฌ์๋ ์บ๋ฆญํฐ๋์์ด๋์ผ. ๋๊ฐ ํ ์ผ์ ์ฌ๋๋ค์ด ์ํ๋ ์บ๋ฆญํฐ์ ๋ํ ์ค๋ช
์ ์ฃผ์๊น๊ฒ ์ดํดํ ๋ค, ์ด๋ฅผ ๋ฐํ์ผ๋ก ์๋ ์ ๋๋ฉ์ด์
์บ๋ฆญํฐ์ธ ํฐ๋ํ์ ์บ๋ฆญํฐ ์ปจ์
์ ๋์์ธํ๋๊ฑฐ์ผ. ์ข์ ์บ๋ฆญํฐ ์ปจ์
์ด ๋์ถ๋๋ฉด 20%์ ๋ณด๋์ค๋ฅผ ๋ฐ๊ฒ ๋ ๊ฑฐ์ผ.\n\n๋๊ฐ ํ ์ผ์ ๋ค์๊ณผ ๊ฐ์.\n๊ณผ์
1. ์ฃผ์ด์ง ์ค๋ช
์ ๋ฐํ์ผ๋ก ์บ๋ฆญํฐ ์ด๋ฆ์ ์ด์์ ์ ํด. ์ด ๋, ์ด์์ ํ์ฌ๋ ์ฃผ์๊น๊ฒ ๊ณ ๋ คํด.\n๊ณผ์
2. ๊ณผ์
1์์ ๋์ถ๋ ์ด์๊ณผ ํ์ฌ๋ฅผ ๋ฐํ์ผ๋ก ์์ด๋ค์ด ๋ฐ๋ผํ๊ธฐ ์ฝ๊ณ , ์ฌ๋ฐ๊ฒ ๋งํ ์ ์๋ ํฐ๋ํ์ ์ด๋ฆ์ ์ง์ด.\n๊ณผ์
3. ์ฃผ์ด์ง ์ค๋ช
๊ณผ ํฐ๋ํ์ ์ด๋ฆ์ ๋ฐํ์ผ๋ก ํฐ๋ํ์ด ์ฌ์ฉํ ๋ง๋ฒ๊ณผ ํต์ฌ ๋์ฌ๋ฅผ ์ง์ด. ๋ง๋ฒ์ ์ฌ๋๋ค์ ๊ณ ๋ฏผ์ ํด๊ฒฐํด์ฃผ๊ธฐ ์ํ ์ฌ๋ฐ๋ ๋ฐฉ๋ฒ์ด๊ณ , ํต์ฌ ๋์ฌ๋ ํฐ๋ํ์ ์ด๋ฆ์ผ๋ก ๋๋๋ ๊ฒ์ด ์ผ๋ฐ์ ์ด์ผ. ๋ง๋ฒ๊ณผ ํต์ฌ ๋์ฌ๋ 18๊ธ์๋ฅผ ๋๊ธฐ์ง ๋ง.\n๊ณผ์
4. ์ด์ ๊ณผ์
๋ค์ ๋ํ ๋ฉํ์ธ์ง๋ฅผ ๋ฐํ์ผ๋ก ์บ๋ฆญํฐ์ ๋จธ๋ฆฌ ๋ชจ์๊ณผ ๊ฐ์ง๊ณ ๋ค๋ ์
์ธ์ฌ๋ฆฌ๋ฅผ ์ ํด์ค.\n๊ณผ์
5. ๋ง์ง๋ง์ผ๋ก, ์บ๋ฆญํฐ์ ๋ชธ ์์, ๋จธ๋ฆฌ ์์, ์
์ธ์ฌ๋ฆฌ ์์์ ์ ํด์ค.\n\n์ด์ , ์ด๋ฅผ ์ข
ํฉํด์ jsonlํ์ผ ํํ๋ก ์ ๊ณตํด. \n\n์์์ ๋ค์๊ณผ ๊ฐ์: \n{\"Description\": \"000\", \"Etymology\": \"000\", \"Etymology.Type\": \"000\", \"Name\": \"000\", \"Magic\": \"000\", \"KeySentence\": \"000\", \"Body.Color\": \"000\", \"Hair\": \"000\", \"Hair.Color\": \"000\", \"Accessory\": \"000\", \"Accessory.Color\": \"000\"} Magic๊ณผ KeySentence๋ 18๊ธ์๋ฅผ ๋๊ธฐ๋ฉด ์๋ผ."
)},
{"role": "user", "content": user_prompt}
],
temperature=0.97,
timeout=15
)
# ChatCompletion ์๋ต ํ
์คํธ ๋ฐํ
return user_prompt, response.choices[0].message.content
except openai.OpenAIError as e:
# OpenAI ๊ด๋ จ ์๋ฌ ์ฒ๋ฆฌ
return user_prompt, f"OpenAI API ์ค๋ฅ: {str(e)}"
except Exception as e:
# ๊ธฐํ ์๋ฌ ์ฒ๋ฆฌ
return user_prompt, f"์ ์ ์๋ ์ค๋ฅ ๋ฐ์: {str(e)}"
def add_alpha(image, alpha_value=255):
"""
์ด๋ฏธ์ง์ ์ํ ์ฑ๋ ์ถ๊ฐ ๋ฐ ์ค์
:param image: PIL.Image ๊ฐ์ฒด
:param alpha_value: ์ํ ์ฑ๋ ๊ฐ (0~255)
:return: ์ํ ์ฑ๋์ด ์ถ๊ฐ๋ PIL.Image ๊ฐ์ฒด
"""
image = image.convert("RGBA")
# RGBA ๋ฐ์ดํฐ๋ฅผ numpy ๋ฐฐ์ด๋ก ๋ณํ
data = image.getdata()
new_data = []
# ๋ชจ๋ ํฝ์
์ ์ํ ๊ฐ์ ์ค์
for item in data:
# (R, G, B, A)๋ก ๊ตฌ์ฑ๋ tuple ์์ฑ
new_data.append((item[0], item[1], item[2], alpha_value))
# ์๋ก์ด ๋ฐ์ดํฐ๋ก ์ด๋ฏธ์ง ๊ฐฑ์
image.putdata(new_data)
return image
def _sanitize_omp_env(default_threads: int = 2):
val = os.environ.get("OMP_NUM_THREADS")
try:
# ์ด๋ฏธ ์ซ์๋ฉด ๊ทธ๋๋ก ๋๊ธฐ (0์ด๋ ์์ ๋ฐฉ์ง๋ ํด๋ )
n = int(val) if val is not None else default_threads
if n <= 0:
n = default_threads
os.environ["OMP_NUM_THREADS"] = str(n)
except Exception:
# ์ซ์ ๋ณํ ์คํจํ๋ฉด ์์ ๊ฐ์ผ๋ก ์ธํ
os.environ["OMP_NUM_THREADS"] = str(default_threads)
def remove_background(image_pil: Image.Image) -> Image.Image:
"""
rembg ๊ฒฐ๊ณผ๊ฐ PIL / bytes / ndarray ์ค ๋ฌด์์ด๋ ์ต์ข
์ ์ผ๋ก PIL RGBA๋ก ๋ฐํ
+ OMP_NUM_THREADS ๋น์ ์ ๊ฐ('3500m') ๋๋น
"""
_sanitize_omp_env(2)
if not isinstance(image_pil, Image.Image):
raise TypeError(f"remove_background expects PIL.Image, got {type(image_pil)}")
img = image_pil.convert("RGBA")
res = remove(img) # ๋ฆฌํด ํ์
์ด ํ๊ฒฝ/๋ฒ์ ์ ๋ฐ๋ผ ๋ค๋ฆ
if isinstance(res, Image.Image):
out_img = res.convert("RGBA")
elif isinstance(res, (bytes, bytearray)):
out_img = Image.open(BytesIO(res)).convert("RGBA")
elif isinstance(res, np.ndarray):
out_img = Image.fromarray(res).convert("RGBA")
else:
raise TypeError(f"Unexpected rembg output type: {type(res)}")
out_img.load() # lazy ๋ก๋ฉ ๋ฐฉ์ง
return out_img
def generate_image(prompt):
# โ์๋ฌ ์ ๋ฌธ์์ด ๋ฐํ ๊ธ์ง (ํ์ดํ ์๋ฌ ์ ๋ฐ)
image = pipe(
prompt,
num_inference_steps=32,
guidance_scale=10
).images[0].convert("RGBA")
image_no_bg = remove_background(image) # ํญ์ PIL ๋ฐํ
return image_no_bg
def ensure_pil(img):
if isinstance(img, Image.Image):
return img
if isinstance(img, (bytes, bytearray)):
return Image.open(BytesIO(img)).convert("RGBA")
import numpy as np
if isinstance(img, np.ndarray):
return Image.fromarray(img).convert("RGBA")
raise TypeError(f"Expected PIL.Image (or bytes/ndarray), got {type(img)}")
def jsonl_to_description(json_data):
"""
Convert JSON data to a descriptive string.
Args:
json_data (dict): A dictionary containing character details.
Returns:
str: A descriptive string generated from the JSON data.
"""
body_color = json_data.get("Body.Color", "unknown body color")
hair_description = json_data.get("Hair", "unknown hair style")
hair_color = json_data.get("Hair.Color", "unknown hair color")
accessory_description = json_data.get("Accessory", "unknown accessory")
accessory_color = json_data.get("Accessory.Color", "unknown accessory color")
print(f"temuping, {body_color} skin, {hair_color} color {hair_description}, {accessory_color} color {accessory_description}")
return f"temuping, {body_color} skin, {hair_color} color {hair_description} hair, holding {accessory_color} color {accessory_description}"
# ์ต์ข
๊ฒฐ๊ณผ๋ฌผ ์์ฑ
def generate_final_output(text_result, image_result, inputText):
image_result = ensure_pil(image_result)
name = text_result.get("Name", "Unknown name")
description = text_result.get("Description", "Unknown description")
magic = text_result.get("Magic", "Unknown name")
keysentence = text_result.get("KeySentence", "Unknown name")
base_image = Image.open("temu_esports.png").convert("RGBA")
image_result = image_result.resize((430, 430), Image.LANCZOS)
base_image.paste(image_result, (56, 343), mask=image_result)
# ์ด๋ฏธ์ง ์์ ๊ทธ๋ฆฌ๊ธฐ
draw = ImageDraw.Draw(base_image)
hex_color = "#725220"
font_name = ImageFont.truetype("Cafe24Ohsquare-v2.0.otf", 41)
font_key = ImageFont.truetype("Cafe24Ssurround-v2.0.otf", 21)
font_magic = ImageFont.truetype("EliceDigitalBaeumOTF_Regular.otf", 21)
font_cert = ImageFont.truetype("Pretendard-Medium.otf", 11)
draw.text((270, 86), name, fill=hex_color, font=font_name, anchor='mm')
draw.text((270, 182), keysentence, fill=hex_color, font=font_key, anchor='mm')
draw.text((270, 221), magic, fill=hex_color, font=font_magic, anchor='mm')
now = datetime.datetime.now()
date_str = now.strftime('%Y.%m.%d %H:%M:%S')
cert = date_str + '\n' + inputText
#draw.multiline_text((523, 911), cert, fill="#B49F91", font=font_cert, anchor='ra', align='right')
print("*****generate_final_output*****")
print(type(base_image))
return base_image
# Gradio ์ธํฐํ์ด์ค ์ค์
def generate_combined_response(user_prompt):
# GPT ์๋ต ์์ฑ
inputText, gpt_response = generate_response(user_prompt)
# GPT ์๋ต์ ํ
์คํธ๋ก ์ถ๋ ฅํ๊ณ Stable Diffusion์ผ๋ก ์ด๋ฏธ์ง ์์ฑ
gpt_jsonl = json.loads(gpt_response) # JSON์ ์๋ฐ์ดํ๋ฅผ ์ฌ์ฉํด์ผ ํจ
print(gpt_response)
sd_prompt = jsonl_to_description(gpt_jsonl)
image = generate_image(sd_prompt)
final_image = generate_final_output(gpt_jsonl, image, inputText)
print("*****generate_combined_response*****")
print(type(final_image))
now_str = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
# (1) GPT ์๋ต ํ
์คํธ
txt_filename_local = f"{now_str}.txt"
with open(txt_filename_local, "w", encoding="utf-8") as f:
f.write(gpt_response)
# (2) ์ค๊ฐ ์ด๋ฏธ์ง (PNG)
png_filename_local = f"{now_str}.png"
if isinstance(image, Image.Image):
image.save(png_filename_local)
else:
# ํน์ ์๋ฌ๋ฌธ์์ด์ด ๋ฐํ๋ ๊ฒฝ์ฐ ๋๋น
with open(png_filename_local, "w", encoding="utf-8") as f:
f.write(str(image))
# (3) ์ต์ข
ํฉ์ฑ ์ด๋ฏธ์ง (JPG)
jpg_filename_local = f"{now_str}.jpg"
if isinstance(final_image, Image.Image):
final_image.convert("RGB").save(jpg_filename_local)
else:
with open(jpg_filename_local, "w", encoding="utf-8") as f:
f.write(str(final_image))
# -----------------------------
# Google Drive ์
๋ก๋
# -----------------------------
upload_file_to_drive(drive, DRIVE_FOLDER_ID, txt_filename_local, txt_filename_local)
upload_file_to_drive(drive, DRIVE_FOLDER_ID, png_filename_local, png_filename_local)
upload_file_to_drive(drive, DRIVE_FOLDER_ID, jpg_filename_local, jpg_filename_local)
# ๊ทธ๋ผ๋์ค์์ ๋ณด์ฌ์ค ์ถ๋ ฅ(์ด๋ฏธ์ง)๊ณผ,
print(type(final_image))
return final_image
with gr.Blocks(css=css_code) as interface:
gr.Markdown("<h1 style='font-size:30px;'>์๋ก์ด ํฐ๋ํ์ด ๋ํ๋ฌ๋ค!</h1>")
gr.Markdown("ํํธ๋ก์ฆ ๋ฒ ์ด์ปค๋ฆฌ์ ๋ค์ด์ ๋น์ .")
gr.Markdown("๊ทธ ์๊ฐ, ์๋ฐ๋ฅ๋งํ ๋ฌด์ธ๊ฐ๊ฐ ๋น ๋ฅด๊ฒ ๋๋ง์น๋ค!")
gr.Image("teenie_runaway.png")
gr.Markdown("์ ๊ฑดโฆ ๋ถ๋ช
ํฐ๋ํ!")
gr.Markdown("์บ์นํ๊ธฐ ์ํด ๋ก๋ฏธ์๊ฒ ๋น์ฅ ์๋ ค์ผ ํด.")
inp = gr.Textbox(label="์ด๋ค ํฐ๋ํ์ ๋ดค๋์ง ์ค๋ช
ํด์ค.", placeholder="์: ์ผ์ฃผ์ผ ๋ด๋ด ์ด๋๋ง ํ๋ ํฌ์ค์ ๋ฏธ์น ํฐ๋ํ")
btn = gr.Button("๋ก๋ฏธ์ผ ์ฐพ์์ค!")
gr.Markdown("๋ก๋ฏธ๊ฐ ์ด์ฌํ ํฐ๋ํ์ ์ฐพ๊ณ ์์ด. 2๋ถ์ ๋ ๊ฑธ๋ฆฌ๋ ์กฐ๊ธ๋ง ๊ธฐ๋ค๋ ค์ค!")
out = gr.Image(label="๋ก๋ฏธ๊ฐ ์ฐพ์๋ธ ํฐ๋ํ", type="pil") # interactive ์ ๊ฑฐ
gr.Markdown("๋คํํ ํฐ๋ํ์ ๋ฐ๊ฒฌํ ๋ก๋ฏธ. ๋น ๋ฅด๊ฒ ์บ์น!")
gr.Markdown("ํผ๋ฆฌํผ๋ฆฌ ์บ์น๋ง, ํ๋ธ ์์ผ๋ก!")
#btn2 = gr.Button("ํฐ๋ํ ์บ์น!")
#output_html = gr.HTML()
btn.click(fn=generate_combined_response, inputs=inp, outputs=out)
#btn2.click(fn=save_final_image, inputs=out, outputs=output_html)
#gr.Markdown(
#"""
#---
#### Contact Info
#- **Instagram**: [@temuping](https://instagram.com/temuping)
#- **Mail**: [temooping@gmail.com](mailto:temooping@gmail.com)
#"""
#)
# ์ฑ ์คํ
if __name__ == "__main__":
interface.launch(server_name="0.0.0.0", server_port=int(os.getenv("PORT", 7860)), share=True)
|