Download app.py from kimpudding/TeeniePingGenerator: direct link, hf CLI and curl.
- Browser
- Download file 16 kB
-
https://huggingface.co/spaces/kimpudding/TeeniePingGenerator/resolve/main/app.py
- Command line
-
hf download hf://spaces/kimpudding/TeeniePingGenerator/app.py
-
curl -L -o app.py https://huggingface.co/spaces/kimpudding/TeeniePingGenerator/resolve/main/app.py
16 kB
| 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) | |