Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -30,6 +30,7 @@ except Exception as e:
|
|
30 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
31 |
|
32 |
dtype = torch.bfloat16 if device == "cuda" else torch.float32
|
|
|
33 |
print(f"Using device: {device}, dtype: {dtype}")
|
34 |
|
35 |
##############################################################################
|
@@ -41,15 +42,18 @@ try:
|
|
41 |
model="Helsinki-NLP/opus-mt-ko-en",
|
42 |
device=0 if device == "cuda" else -1
|
43 |
)
|
|
|
44 |
pipe = DiffusionPipeline.from_pretrained(
|
45 |
"black-forest-labs/FLUX.1-schnell",
|
46 |
torch_dtype=dtype
|
47 |
).to(device)
|
|
|
48 |
print("Models loaded successfully")
|
49 |
except Exception as e:
|
50 |
print(f"Error loading models: {e}")
|
51 |
def dummy_translator(text):
|
52 |
return [{'translation_text': text}]
|
|
|
53 |
class DummyPipe:
|
54 |
def __call__(self, **kwargs):
|
55 |
from PIL import Image
|
@@ -59,6 +63,7 @@ except Exception as e:
|
|
59 |
def __init__(self, img):
|
60 |
self.images = [img]
|
61 |
return DummyResult(dummy_img)
|
|
|
62 |
translator = dummy_translator
|
63 |
pipe = DummyPipe()
|
64 |
|
@@ -97,19 +102,25 @@ def log_unexpected_characters(text):
|
|
97 |
def generate_design_image(prompt, seed=42, randomize_seed=True, width=1024, height=1024, num_inference_steps=4):
|
98 |
original_prompt = prompt
|
99 |
translated = False
|
|
|
100 |
# Clean the input text
|
101 |
prompt = clean_input_text(prompt)
|
|
|
102 |
# Pre-process: if input is too long, trim to 1000 characters
|
103 |
if len(prompt) > 1000:
|
104 |
prompt = prompt[:1000]
|
|
|
105 |
if contains_korean(prompt):
|
106 |
# When calling translation, add max_length and truncation options to avoid length issues
|
107 |
translation = translator(prompt, max_length=400, truncation=True)
|
108 |
prompt = translation[0]['translation_text']
|
109 |
translated = True
|
|
|
110 |
if randomize_seed:
|
111 |
seed = random.randint(0, MAX_SEED)
|
|
|
112 |
generator = torch.Generator(device=device).manual_seed(seed)
|
|
|
113 |
image = pipe(
|
114 |
prompt=prompt,
|
115 |
width=width,
|
@@ -118,6 +129,7 @@ def generate_design_image(prompt, seed=42, randomize_seed=True, width=1024, heig
|
|
118 |
generator=generator,
|
119 |
guidance_scale=0.0
|
120 |
).images[0]
|
|
|
121 |
return image
|
122 |
|
123 |
##############################################################################
|
@@ -245,6 +257,271 @@ physical_transformation_categories = {
|
|
245 |
"๊ด๋ ๋ณํ"
|
246 |
],
|
247 |
"์๋ฆฌ์ ์ง๋ ํจ๊ณผ": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
"Sound generation/cessation", "Pitch change", "Volume change", "Timbre change",
|
249 |
"Resonance/antiresonance", "Acoustic vibration", "Ultrasonic/infrasonic emission", "Sound concentration/distribution",
|
250 |
"Sound reflection/absorption", "Acoustic Doppler effect", "Sound wave interference", "Acoustic resonance",
|
@@ -290,7 +567,20 @@ physical_transformation_categories = {
|
|
290 |
"Radiation response", "Vibration detection", "pH response", "Solvent response", "Gas exchange",
|
291 |
"Pollution response", "Weather response", "Seasonal response", "Circadian response", "Ecosystem interaction",
|
292 |
"Symbiotic/competitive interaction", "Predator/prey relationship", "Swarm formation", "Territorial behavior", "Migration/settlement pattern"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
293 |
]
|
|
|
294 |
}
|
295 |
|
296 |
##############################################################################
|
@@ -433,8 +723,10 @@ def process_inputs_lang(text1, text2, text3, selected_category, categories_dict,
|
|
433 |
text1 = text1.strip() if text1 else None
|
434 |
text2 = text2.strip() if text2 else None
|
435 |
text3 = text3.strip() if text3 else None
|
|
|
436 |
if not text1:
|
437 |
return "์ค๋ฅ: ์ต์ ํ๋์ ํค์๋๋ฅผ ์
๋ ฅํด์ฃผ์ธ์." if lang=="ko" else "Error: Please enter at least one keyword."
|
|
|
438 |
if lang == "ko":
|
439 |
progress(0.05, desc="์์ด๋์ด ์์ฑ ์ค๋น ์ค...")
|
440 |
time.sleep(0.3)
|
@@ -443,7 +735,9 @@ def process_inputs_lang(text1, text2, text3, selected_category, categories_dict,
|
|
443 |
progress(0.05, desc="Preparing idea generation...")
|
444 |
time.sleep(0.3)
|
445 |
progress(0.1, desc="Generating creative idea...")
|
|
|
446 |
results = generate_transformations_lang(text1, text2, text3, selected_category, categories_dict, lang)
|
|
|
447 |
if lang == "ko":
|
448 |
progress(0.8, desc="๊ฒฐ๊ณผ ํฌ๋งทํ
์ค...")
|
449 |
formatted = format_results_lang(results, lang)
|
@@ -474,41 +768,6 @@ def get_warning_message_lang(lang="ko"):
|
|
474 |
return "โ ๏ธ ํ๊ฒฝ ๋ณ์ GEMINI_API_KEY๊ฐ ์ค์ ๋์ง ์์์ต๋๋ค. Gemini API ํค๋ฅผ ์ค์ ํ์ธ์." if lang=="ko" else "โ ๏ธ The GEMINI_API_KEY environment variable is not set. Please set your Gemini API key."
|
475 |
return ""
|
476 |
|
477 |
-
##############################################################################
|
478 |
-
# Add "Business Ideas" category to each dictionary
|
479 |
-
##############################################################################
|
480 |
-
physical_transformation_categories["๋น์ฆ๋์ค ์์ด๋์ด"] = [
|
481 |
-
"์์ฅ ์ฌ์ ์/์ ๊ท ์์ฅ ๊ฐ์ฒ",
|
482 |
-
"๋น์ฆ๋์ค ๋ชจ๋ธ ํ์ /๋์งํธ ์ ํ",
|
483 |
-
"๊ณ ๊ฐ ๊ฒฝํ ํ์ /์๋น์ค ํ์ ",
|
484 |
-
"ํ๋ ฅ ๋ฐ ํํธ๋์ญ ๊ฐํ/์ํ๊ณ ๊ตฌ์ถ",
|
485 |
-
"๊ธ๋ก๋ฒ ํ์ฅ/์ง์ญํ ์ ๋ต",
|
486 |
-
"์ด์ ํจ์จ์ฑ ์ฆ๋/์๊ฐ ์ ๊ฐ",
|
487 |
-
"๋ธ๋๋ ๋ฆฌํฌ์ง์
๋/์ด๋ฏธ์ง ์ ํ",
|
488 |
-
"์ง์ ๊ฐ๋ฅํ ์ฑ์ฅ/์ฌํ์ ๊ฐ์น ์ฐฝ์ถ",
|
489 |
-
"๋ฐ์ดํฐ ๊ธฐ๋ฐ ์์ฌ๊ฒฐ์ /AI ๋์
",
|
490 |
-
"์ ๊ธฐ์ ์ตํฉ/ํ์ ํฌ์"
|
491 |
-
]
|
492 |
-
|
493 |
-
physical_transformation_categories_en["Business Ideas"] = [
|
494 |
-
"Market redefinition/new market creation",
|
495 |
-
"Business model innovation/digital transformation",
|
496 |
-
"Customer experience and service innovation",
|
497 |
-
"Enhanced partnerships and ecosystem building",
|
498 |
-
"Global expansion and localization strategy",
|
499 |
-
"Operational efficiency improvement/cost reduction",
|
500 |
-
"Brand repositioning/image transformation",
|
501 |
-
"Sustainable growth and social value creation",
|
502 |
-
"Data-driven decision making/AI adoption",
|
503 |
-
"Convergence of new technologies/innovative investments"
|
504 |
-
]
|
505 |
-
|
506 |
-
##############################################################################
|
507 |
-
# Helper function for caching examples in the English tab
|
508 |
-
##############################################################################
|
509 |
-
def process_all_lang_example(text1, text2, text3, selected_category):
|
510 |
-
# ๊ณ ์ ๋ state๊ฐ(physical_transformation_categories_en, "en")์ผ๋ก ํธ์ถ
|
511 |
-
return process_all_lang(text1, text2, text3, selected_category, physical_transformation_categories_en, "en")
|
512 |
|
513 |
##############################################################################
|
514 |
# Gradio UI with Two Tabs: English (Main Home) and Korean
|
@@ -517,6 +776,7 @@ with gr.Blocks(
|
|
517 |
title="Idea Transformer",
|
518 |
theme=gr.themes.Soft(primary_hue="teal", secondary_hue="slate", neutral_hue="neutral")
|
519 |
) as demo:
|
|
|
520 |
gr.HTML("""
|
521 |
<style>
|
522 |
body {
|
@@ -559,7 +819,9 @@ with gr.Blocks(
|
|
559 |
with gr.Tab(label="English"):
|
560 |
gr.Markdown("# ๐ Idea Transformer")
|
561 |
gr.Markdown("Based on up to **three keywords** and a **selected category**, this tool generates a creative transformation idea and a design image using the expanded idea as a prompt. https://discord.gg/openfreeai")
|
|
|
562 |
warning_en = gr.Markdown(get_warning_message_lang("en"))
|
|
|
563 |
with gr.Row():
|
564 |
with gr.Column(scale=1):
|
565 |
text_input1_en = gr.Textbox(label="Keyword 1 (required)", placeholder="e.g., Smartphone")
|
@@ -572,6 +834,7 @@ with gr.Blocks(
|
|
572 |
info="Select a category."
|
573 |
)
|
574 |
status_msg_en = gr.Markdown("๐ก Click the 'Generate Idea' button to create an idea and design image based on the selected category.")
|
|
|
575 |
processing_indicator_en = gr.HTML("""
|
576 |
<div style="display: flex; justify-content: center; align-items: center; margin: 10px 0;">
|
577 |
<div style="border: 5px solid #f3f3f3; border-top: 5px solid #3498db; border-radius: 50%; width: 30px; height: 30px; animation: spin 2s linear infinite;"></div>
|
@@ -584,10 +847,13 @@ with gr.Blocks(
|
|
584 |
}
|
585 |
</style>
|
586 |
""", visible=False)
|
|
|
587 |
submit_button_en = gr.Button("Generate Idea", variant="primary")
|
|
|
588 |
with gr.Column(scale=2):
|
589 |
idea_output_en = gr.Markdown(label="Idea Output")
|
590 |
generated_image_en = gr.Image(label="Generated Design Image", type="pil")
|
|
|
591 |
gr.Examples(
|
592 |
examples=[
|
593 |
["Smartphone", "", "", "Sensor Functions"],
|
@@ -597,14 +863,14 @@ with gr.Blocks(
|
|
597 |
["Sneakers", "Wearable", "Health", "Structural Change"],
|
598 |
],
|
599 |
inputs=[text_input1_en, text_input2_en, text_input3_en, category_radio_en],
|
600 |
-
fn=process_all_lang_example,
|
601 |
-
outputs=[idea_output_en, generated_image_en],
|
602 |
-
cache_examples=True
|
603 |
)
|
|
|
604 |
def show_processing_indicator_en():
|
605 |
return gr.update(visible=True)
|
|
|
606 |
def hide_processing_indicator_en():
|
607 |
return gr.update(visible=False)
|
|
|
608 |
submit_button_en.click(
|
609 |
fn=show_processing_indicator_en,
|
610 |
inputs=None,
|
@@ -618,10 +884,13 @@ with gr.Blocks(
|
|
618 |
inputs=None,
|
619 |
outputs=processing_indicator_en
|
620 |
)
|
|
|
621 |
with gr.Tab(label="ํ๊ตญ์ด"):
|
622 |
gr.Markdown("# ๐ ์์ด๋์ด ํธ๋์คํฌ๋จธ")
|
623 |
gr.Markdown("์
๋ ฅํ **ํค์๋**(์ต๋ 3๊ฐ)์ **์นดํ
๊ณ ๋ฆฌ**๋ฅผ ๋ฐํ์ผ๋ก, ์ฐฝ์์ ์ธ ๋ชจ๋ธ/์ปจ์
/ํ์ ๋ณํ ์์ด๋์ด๋ฅผ ์์ฑํ๊ณ , ํด๋น ํ์ฅ ์์ด๋์ด๋ฅผ ํ๋กฌํํธ๋ก ํ์ฌ ๋์์ธ ์ด๋ฏธ์ง๋ฅผ ์์ฑํฉ๋๋ค. https://discord.gg/openfreeai")
|
|
|
624 |
warning_ko = gr.Markdown(get_warning_message_lang("ko"))
|
|
|
625 |
with gr.Row():
|
626 |
with gr.Column(scale=1):
|
627 |
text_input1_ko = gr.Textbox(label="ํค์๋ 1 (ํ์)", placeholder="์: ์ค๋งํธํฐ")
|
@@ -634,6 +903,7 @@ with gr.Blocks(
|
|
634 |
info="์ถ๋ ฅํ ์นดํ
๊ณ ๋ฆฌ๋ฅผ ์ ํํ์ธ์."
|
635 |
)
|
636 |
status_msg_ko = gr.Markdown("๐ก '์์ด๋์ด ์์ฑํ๊ธฐ' ๋ฒํผ์ ํด๋ฆญํ๋ฉด ์ ํํ ์นดํ
๊ณ ๋ฆฌ์ ํด๋นํ๋ ์์ด๋์ด์ ๋์์ธ ์ด๋ฏธ์ง๊ฐ ์์ฑ๋ฉ๋๋ค.")
|
|
|
637 |
processing_indicator_ko = gr.HTML("""
|
638 |
<div style="display: flex; justify-content: center; align-items: center; margin: 10px 0;">
|
639 |
<div style="border: 5px solid #f3f3f3; border-top: 5px solid #3498db; border-radius: 50%; width: 30px; height: 30px; animation: spin 2s linear infinite;"></div>
|
@@ -646,10 +916,13 @@ with gr.Blocks(
|
|
646 |
}
|
647 |
</style>
|
648 |
""", visible=False)
|
|
|
649 |
submit_button_ko = gr.Button("์์ด๋์ด ์์ฑํ๊ธฐ", variant="primary")
|
|
|
650 |
with gr.Column(scale=2):
|
651 |
idea_output_ko = gr.Markdown(label="์์ด๋์ด ๊ฒฐ๊ณผ")
|
652 |
generated_image_ko = gr.Image(label="์์ฑ๋ ๋์์ธ ์ด๋ฏธ์ง", type="pil")
|
|
|
653 |
gr.Examples(
|
654 |
examples=[
|
655 |
["์ค๋งํธํฐ", "", "", "์ผ์ ๊ธฐ๋ฅ"],
|
@@ -658,12 +931,15 @@ with gr.Blocks(
|
|
658 |
["๋๋ก ", "์ธ๊ณต์ง๋ฅ", "", "๋ฌผ์ง์ ์ํ ๋ณํ"],
|
659 |
["์ด๋ํ", "์จ์ด๋ฌ๋ธ", "๊ฑด๊ฐ", "๊ตฌ์กฐ์ ๋ณํ"],
|
660 |
],
|
661 |
-
inputs=[text_input1_ko, text_input2_ko, text_input3_ko, category_radio_ko]
|
662 |
)
|
|
|
663 |
def show_processing_indicator_ko():
|
664 |
return gr.update(visible=True)
|
|
|
665 |
def hide_processing_indicator_ko():
|
666 |
return gr.update(visible=False)
|
|
|
667 |
submit_button_ko.click(
|
668 |
fn=show_processing_indicator_ko,
|
669 |
inputs=None,
|
@@ -679,4 +955,4 @@ with gr.Blocks(
|
|
679 |
)
|
680 |
|
681 |
if __name__ == "__main__":
|
682 |
-
demo.launch(debug=True)
|
|
|
30 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
31 |
|
32 |
dtype = torch.bfloat16 if device == "cuda" else torch.float32
|
33 |
+
|
34 |
print(f"Using device: {device}, dtype: {dtype}")
|
35 |
|
36 |
##############################################################################
|
|
|
42 |
model="Helsinki-NLP/opus-mt-ko-en",
|
43 |
device=0 if device == "cuda" else -1
|
44 |
)
|
45 |
+
|
46 |
pipe = DiffusionPipeline.from_pretrained(
|
47 |
"black-forest-labs/FLUX.1-schnell",
|
48 |
torch_dtype=dtype
|
49 |
).to(device)
|
50 |
+
|
51 |
print("Models loaded successfully")
|
52 |
except Exception as e:
|
53 |
print(f"Error loading models: {e}")
|
54 |
def dummy_translator(text):
|
55 |
return [{'translation_text': text}]
|
56 |
+
|
57 |
class DummyPipe:
|
58 |
def __call__(self, **kwargs):
|
59 |
from PIL import Image
|
|
|
63 |
def __init__(self, img):
|
64 |
self.images = [img]
|
65 |
return DummyResult(dummy_img)
|
66 |
+
|
67 |
translator = dummy_translator
|
68 |
pipe = DummyPipe()
|
69 |
|
|
|
102 |
def generate_design_image(prompt, seed=42, randomize_seed=True, width=1024, height=1024, num_inference_steps=4):
|
103 |
original_prompt = prompt
|
104 |
translated = False
|
105 |
+
|
106 |
# Clean the input text
|
107 |
prompt = clean_input_text(prompt)
|
108 |
+
|
109 |
# Pre-process: if input is too long, trim to 1000 characters
|
110 |
if len(prompt) > 1000:
|
111 |
prompt = prompt[:1000]
|
112 |
+
|
113 |
if contains_korean(prompt):
|
114 |
# When calling translation, add max_length and truncation options to avoid length issues
|
115 |
translation = translator(prompt, max_length=400, truncation=True)
|
116 |
prompt = translation[0]['translation_text']
|
117 |
translated = True
|
118 |
+
|
119 |
if randomize_seed:
|
120 |
seed = random.randint(0, MAX_SEED)
|
121 |
+
|
122 |
generator = torch.Generator(device=device).manual_seed(seed)
|
123 |
+
|
124 |
image = pipe(
|
125 |
prompt=prompt,
|
126 |
width=width,
|
|
|
129 |
generator=generator,
|
130 |
guidance_scale=0.0
|
131 |
).images[0]
|
132 |
+
|
133 |
return image
|
134 |
|
135 |
##############################################################################
|
|
|
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 |
+
"pH ๋ณํ",
|
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 |
+
"์์ฒด ์ญํ์ ๋ฐ์",
|
399 |
+
"์ธํฌ ์ด๋์ฑ",
|
400 |
+
"์ธํฌ ๊ทน์ฑ ๋ณํ",
|
401 |
+
"์์ ์ํ ๋ณํ"
|
402 |
+
],
|
403 |
+
"ํ๊ฒฝ ์ํธ์์ฉ": [
|
404 |
+
"์จ๋ ๋ฐ์",
|
405 |
+
"์ต๋ ๋ฐ์",
|
406 |
+
"๊ธฐ์ ๋ฐ์",
|
407 |
+
"์ค๋ ฅ ๋ฐ์",
|
408 |
+
"์๊ธฐ์ฅ ๋ฐ์",
|
409 |
+
"๋น ๋ฐ์",
|
410 |
+
"์๋ฆฌ ๋ฐ์",
|
411 |
+
"ํํ ๋ฌผ์ง ๊ฐ์ง",
|
412 |
+
"๊ธฐ๊ณ์ ์๊ทน ๊ฐ์ง",
|
413 |
+
"์ ๊ธฐ ์๊ทน ๋ฐ์",
|
414 |
+
"๋ฐฉ์ฌ์ ๋ฐ์",
|
415 |
+
"์ง๋ ๊ฐ์ง",
|
416 |
+
"pH ๋ฐ์",
|
417 |
+
"์ฉ๋งค ๋ฐ์",
|
418 |
+
"๊ธฐ์ฒด ๊ตํ",
|
419 |
+
"ํ๊ฒฝ ์ค์ผ ๋ฐ์",
|
420 |
+
"๋ ์จ ๋ฐ์",
|
421 |
+
"๊ณ์ ๋ฐ์",
|
422 |
+
"์ผ์ฃผ๊ธฐ ๋ฐ์",
|
423 |
+
"์ํ๊ณ ์ํธ์์ฉ",
|
424 |
+
"๊ณต์/๊ฒฝ์ ๋ฐ์",
|
425 |
+
"ํฌ์/ํผ์ ๊ด๊ณ",
|
426 |
+
"๊ตฐ์ง ํ์ฑ",
|
427 |
+
"์์ญ ์ค์ ",
|
428 |
+
"์ด์ฃผ/์ ์ฐฉ ํจํด"
|
429 |
+
],
|
430 |
+
|
431 |
+
"๋น์ฆ๋์ค ์์ด๋์ด: [
|
432 |
+
"์์ฅ ์ฌ์ ์/์ ๊ท ์์ฅ ๊ฐ์ฒ",
|
433 |
+
"๋น์ฆ๋์ค ๋ชจ๋ธ ํ์ /๋์งํธ ์ ํ",
|
434 |
+
"๊ณ ๊ฐ ๊ฒฝํ ํ์ /์๋น์ค ํ์ ",
|
435 |
+
"ํ๋ ฅ ๋ฐ ํํธ๋์ญ ๊ฐํ/์ํ๊ณ ๊ตฌ์ถ",
|
436 |
+
"๊ธ๋ก๋ฒ ํ์ฅ/์ง์ญํ ์ ๋ต",
|
437 |
+
"์ด์ ํจ์จ์ฑ ์ฆ๋/์๊ฐ ์ ๊ฐ",
|
438 |
+
"๋ธ๋๋ ๋ฆฌํฌ์ง์
๋/์ด๋ฏธ์ง ์ ํ",
|
439 |
+
"์ง์ ๊ฐ๋ฅํ ์ฑ์ฅ/์ฌํ์ ๊ฐ์น ์ฐฝ์ถ",
|
440 |
+
"๋ฐ์ดํฐ ๊ธฐ๋ฐ ์์ฌ๊ฒฐ์ /AI ๋์
",
|
441 |
+
"์ ๊ธฐ์ ์ตํฉ/ํ์ ํฌ์"
|
442 |
+
]
|
443 |
+
|
444 |
+
}
|
445 |
+
|
446 |
+
# English version
|
447 |
+
physical_transformation_categories_en = {
|
448 |
+
"Sensor Functions": [
|
449 |
+
"Visual sensor/detection", "Auditory sensor/detection", "Tactile sensor/detection", "Taste sensor/detection", "Olfactory sensor/detection",
|
450 |
+
"Temperature sensor/detection", "Humidity sensor/detection", "Pressure sensor/detection", "Acceleration sensor/detection", "Rotational sensor/detection",
|
451 |
+
"Proximity sensor/detection", "Position sensor/detection", "Motion sensor/detection", "Gas sensor/detection", "Infrared sensor/detection",
|
452 |
+
"Ultraviolet sensor/detection", "Radiation sensor/detection", "Magnetic sensor/detection", "Electric field sensor/detection", "Chemical sensor/detection",
|
453 |
+
"Biosignal sensor/detection", "Vibration sensor/detection", "Noise sensor/detection", "Light intensity sensor/detection", "Light wavelength sensor/detection",
|
454 |
+
"Tilt sensor/detection", "pH sensor/detection", "Current sensor/detection", "Voltage sensor/detection", "Image sensor/detection",
|
455 |
+
"Distance sensor/detection", "Depth sensor/detection", "Gravity sensor/detection", "Speed sensor/detection", "Flow sensor/detection",
|
456 |
+
"Water level sensor/detection", "Turbidity sensor/detection", "Salinity sensor/detection", "Metal detection", "Piezoelectric sensor/detection",
|
457 |
+
"Photovoltaic sensor/detection", "Thermocouple sensor/detection", "Hall effect sensor/detection", "Ultrasonic sensor/detection", "Radar sensor/detection",
|
458 |
+
"Lidar sensor/detection", "Touch sensor/detection", "Gesture sensor/detection", "Heart rate sensor/detection", "Blood pressure sensor/detection"
|
459 |
+
],
|
460 |
+
"Size and Shape Change": [
|
461 |
+
"Volume increase/decrease", "Length increase/decrease", "Width increase/decrease", "Height increase/decrease",
|
462 |
+
"Density change", "Weight increase/decrease", "Shape deformation", "State change", "Uneven deformation",
|
463 |
+
"Complex shape deformation", "Twisting/entwining", "Non-uniform expansion/contraction", "Rounded/sharpened edges",
|
464 |
+
"Cracking/splitting", "Fragmentation", "Water resistance", "Dust resistance", "Denting/recovery",
|
465 |
+
"Folding/unfolding", "Compression/expansion", "Stretching/contraction", "Wrinkling/flattening", "Crushing/hardening",
|
466 |
+
"Rolling/unrolling", "Bending/curving"
|
467 |
+
],
|
468 |
+
"Surface and Appearance Change": [
|
469 |
+
"Color change", "Texture change", "Transparency change", "Glossy/matte change",
|
470 |
+
"Light reflection variation", "Pattern change", "Angle-dependent color change", "Light-induced color change",
|
471 |
+
"Temperature-dependent color change", "Holographic effect", "Angle-specific light reflection", "Surface shape alteration",
|
472 |
+
"Nano-scale surface structure change", "Self-cleaning effect", "Stain/pattern formation", "Blurriness/clarity change",
|
473 |
+
"Luster/shine change", "Hue/saturation change", "Luminescence/fluorescence", "Light scattering effect",
|
474 |
+
"Light absorption change", "Translucency effect", "Shadow effect change", "UV response change",
|
475 |
+
"Glow effect"
|
476 |
+
],
|
477 |
+
"Material State Change": [
|
478 |
+
"Solid/liquid/gas transition", "Crystallization/dissolution", "Oxidation/corrosion", "Hardening/softening",
|
479 |
+
"Special state transition", "Amorphous/crystalline transition", "Component separation", "Particle formation/disintegration",
|
480 |
+
"Gel formation/dissolution", "Metastable state change", "Molecular self-assembly/disintegration", "Delayed state change",
|
481 |
+
"Melting", "Solidification", "Evaporation/condensation", "Sublimation/deposition", "Precipitation/suspension", "Dispersion/aggregation",
|
482 |
+
"Drying/moistening", "Swelling/shrinkage", "Freezing/thawing", "Weathering/erosion", "Charging/discharging",
|
483 |
+
"Bonding/separation", "Fermentation/decay"
|
484 |
+
],
|
485 |
+
"Movement Characteristics Change": [
|
486 |
+
"Acceleration/deceleration", "Maintaining constant speed", "Vibration/vibration reduction", "Collision/bouncing",
|
487 |
+
"Increase/decrease in rotational speed", "Change in rotational direction", "Irregular movement", "Stop-and-slide phenomenon",
|
488 |
+
"Resonance/anti-resonance", "Resistance/lift change in fluid", "Change in movement resistance", "Complex vibrational movement",
|
489 |
+
"Movement in special fluid", "Rotational-translational movement", "Inertial stoppage", "Shock absorption",
|
490 |
+
"Shock transfer", "Conservation of momentum", "Friction change", "Overcoming inertia", "Unstable equilibrium",
|
491 |
+
"Dynamic stability", "Damping of oscillation", "Path predictability", "Evasive movement"
|
492 |
+
],
|
493 |
+
"Structural Change": [
|
494 |
+
"Addition/removal of components", "Assembly/disassembly", "Folding/unfolding", "Deformation/recovery", "Optimal structural change",
|
495 |
+
"Self-rearrangement", "Natural pattern formation/disappearance", "Regular pattern change", "Modular transformation",
|
496 |
+
"Increased structural complexity", "Memory of original shape effect", "Shape change over time", "Partial removal",
|
497 |
+
"Partial replacement", "Bonding", "Separation", "Division/integration", "Overlaying", "Internal structure change",
|
498 |
+
"External structure change", "Shift of center axis", "Balance point change", "Hierarchical structure change", "Support structure change",
|
499 |
+
"Stress distribution structure", "Shock absorption structure", "Grid/matrix structure change", "Interconnectivity change"
|
500 |
+
],
|
501 |
+
"Spatial Movement": [
|
502 |
+
"Forward/backward movement", "Left/right movement", "Up/down movement", "Vertical axis rotation (nodding)",
|
503 |
+
"Horizontal axis rotation (shaking head)", "Longitudinal axis rotation (tilting sideways)", "Circular motion", "Spiral movement",
|
504 |
+
"Slipping due to inertia", "Change of rotation axis", "Irregular rotation", "Shaking movement", "Parabolic motion",
|
505 |
+
"Zero-gravity floating", "Floating on water surface", "Jump/leap", "Sliding", "Rolling", "Free fall",
|
506 |
+
"Reciprocating motion", "Elastic bouncing", "Penetration", "Evasive movement", "Zigzag movement", "Swinging movement"
|
507 |
+
],
|
508 |
+
"Time-Related Change": [
|
509 |
+
"Aging/weathering", "Wear/corrosion", "Fading/discoloration", "Damage/recovery", "Lifecycle change",
|
510 |
+
"Adaptation through user interaction", "Learning-based shape optimization", "Property change over time",
|
511 |
+
"Collective memory effect", "Cultural significance change", "Delayed response", "History-dependent change",
|
512 |
+
"Gradual time change", "Evolutionary change", "Periodic regeneration", "Seasonal adaptation",
|
513 |
+
"Circadian rhythm change", "Lifecycle stage", "Growth/decline", "Self-repair/regeneration",
|
514 |
+
"Natural cycle adaptation", "Persistence/transience", "Memory effect", "Delayed effect", "Cumulative effect"
|
515 |
+
],
|
516 |
+
"Light and Visual Effects": [
|
517 |
+
"Illumination/shutdown", "Light transmission/blocking", "Light scattering/concentration", "Color spectrum change", "Light diffraction",
|
518 |
+
"Light interference", "Hologram creation", "Laser effect", "Light polarization", "Fluorescence/phosphorescence",
|
519 |
+
"UV/IR emission", "Optical illusion", "Light refraction", "Shadow creation/removal",
|
520 |
+
"Chromatic aberration", "Rainbow effect", "Glow effect", "Flash effect", "Lighting pattern",
|
521 |
+
"Beam effect", "Light filter effect", "Change in light direction", "Projection effect", "Light detection/response",
|
522 |
+
"Luminance change"
|
523 |
+
],
|
524 |
+
"Sound and Vibration Effects": [
|
525 |
"Sound generation/cessation", "Pitch change", "Volume change", "Timbre change",
|
526 |
"Resonance/antiresonance", "Acoustic vibration", "Ultrasonic/infrasonic emission", "Sound concentration/distribution",
|
527 |
"Sound reflection/absorption", "Acoustic Doppler effect", "Sound wave interference", "Acoustic resonance",
|
|
|
567 |
"Radiation response", "Vibration detection", "pH response", "Solvent response", "Gas exchange",
|
568 |
"Pollution response", "Weather response", "Seasonal response", "Circadian response", "Ecosystem interaction",
|
569 |
"Symbiotic/competitive interaction", "Predator/prey relationship", "Swarm formation", "Territorial behavior", "Migration/settlement pattern"
|
570 |
+
],
|
571 |
+
"Business Ideas": [
|
572 |
+
"Market redefinition / New market creation",
|
573 |
+
"Business model innovation / Digital transformation",
|
574 |
+
"Customer experience innovation / Service innovation",
|
575 |
+
"Strengthened collaboration and partnerships / Ecosystem building",
|
576 |
+
"Global expansion / Localization strategy",
|
577 |
+
"Increased operational efficiency / Cost reduction",
|
578 |
+
"Brand repositioning / Image transformation",
|
579 |
+
"Sustainable growth / Social value creation",
|
580 |
+
"Data-driven decision making / AI adoption",
|
581 |
+
"Convergence of new technologies / Innovative investments"
|
582 |
]
|
583 |
+
|
584 |
}
|
585 |
|
586 |
##############################################################################
|
|
|
723 |
text1 = text1.strip() if text1 else None
|
724 |
text2 = text2.strip() if text2 else None
|
725 |
text3 = text3.strip() if text3 else None
|
726 |
+
|
727 |
if not text1:
|
728 |
return "์ค๋ฅ: ์ต์ ํ๋์ ํค์๋๋ฅผ ์
๋ ฅํด์ฃผ์ธ์." if lang=="ko" else "Error: Please enter at least one keyword."
|
729 |
+
|
730 |
if lang == "ko":
|
731 |
progress(0.05, desc="์์ด๋์ด ์์ฑ ์ค๋น ์ค...")
|
732 |
time.sleep(0.3)
|
|
|
735 |
progress(0.05, desc="Preparing idea generation...")
|
736 |
time.sleep(0.3)
|
737 |
progress(0.1, desc="Generating creative idea...")
|
738 |
+
|
739 |
results = generate_transformations_lang(text1, text2, text3, selected_category, categories_dict, lang)
|
740 |
+
|
741 |
if lang == "ko":
|
742 |
progress(0.8, desc="๊ฒฐ๊ณผ ํฌ๋งทํ
์ค...")
|
743 |
formatted = format_results_lang(results, lang)
|
|
|
768 |
return "โ ๏ธ ํ๊ฒฝ ๋ณ์ GEMINI_API_KEY๊ฐ ์ค์ ๋์ง ์์์ต๋๋ค. Gemini API ํค๋ฅผ ์ค์ ํ์ธ์." if lang=="ko" else "โ ๏ธ The GEMINI_API_KEY environment variable is not set. Please set your Gemini API key."
|
769 |
return ""
|
770 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
771 |
|
772 |
##############################################################################
|
773 |
# Gradio UI with Two Tabs: English (Main Home) and Korean
|
|
|
776 |
title="Idea Transformer",
|
777 |
theme=gr.themes.Soft(primary_hue="teal", secondary_hue="slate", neutral_hue="neutral")
|
778 |
) as demo:
|
779 |
+
|
780 |
gr.HTML("""
|
781 |
<style>
|
782 |
body {
|
|
|
819 |
with gr.Tab(label="English"):
|
820 |
gr.Markdown("# ๐ Idea Transformer")
|
821 |
gr.Markdown("Based on up to **three keywords** and a **selected category**, this tool generates a creative transformation idea and a design image using the expanded idea as a prompt. https://discord.gg/openfreeai")
|
822 |
+
|
823 |
warning_en = gr.Markdown(get_warning_message_lang("en"))
|
824 |
+
|
825 |
with gr.Row():
|
826 |
with gr.Column(scale=1):
|
827 |
text_input1_en = gr.Textbox(label="Keyword 1 (required)", placeholder="e.g., Smartphone")
|
|
|
834 |
info="Select a category."
|
835 |
)
|
836 |
status_msg_en = gr.Markdown("๐ก Click the 'Generate Idea' button to create an idea and design image based on the selected category.")
|
837 |
+
|
838 |
processing_indicator_en = gr.HTML("""
|
839 |
<div style="display: flex; justify-content: center; align-items: center; margin: 10px 0;">
|
840 |
<div style="border: 5px solid #f3f3f3; border-top: 5px solid #3498db; border-radius: 50%; width: 30px; height: 30px; animation: spin 2s linear infinite;"></div>
|
|
|
847 |
}
|
848 |
</style>
|
849 |
""", visible=False)
|
850 |
+
|
851 |
submit_button_en = gr.Button("Generate Idea", variant="primary")
|
852 |
+
|
853 |
with gr.Column(scale=2):
|
854 |
idea_output_en = gr.Markdown(label="Idea Output")
|
855 |
generated_image_en = gr.Image(label="Generated Design Image", type="pil")
|
856 |
+
|
857 |
gr.Examples(
|
858 |
examples=[
|
859 |
["Smartphone", "", "", "Sensor Functions"],
|
|
|
863 |
["Sneakers", "Wearable", "Health", "Structural Change"],
|
864 |
],
|
865 |
inputs=[text_input1_en, text_input2_en, text_input3_en, category_radio_en],
|
|
|
|
|
|
|
866 |
)
|
867 |
+
|
868 |
def show_processing_indicator_en():
|
869 |
return gr.update(visible=True)
|
870 |
+
|
871 |
def hide_processing_indicator_en():
|
872 |
return gr.update(visible=False)
|
873 |
+
|
874 |
submit_button_en.click(
|
875 |
fn=show_processing_indicator_en,
|
876 |
inputs=None,
|
|
|
884 |
inputs=None,
|
885 |
outputs=processing_indicator_en
|
886 |
)
|
887 |
+
|
888 |
with gr.Tab(label="ํ๊ตญ์ด"):
|
889 |
gr.Markdown("# ๐ ์์ด๋์ด ํธ๋์คํฌ๋จธ")
|
890 |
gr.Markdown("์
๋ ฅํ **ํค์๋**(์ต๋ 3๊ฐ)์ **์นดํ
๊ณ ๋ฆฌ**๋ฅผ ๋ฐํ์ผ๋ก, ์ฐฝ์์ ์ธ ๋ชจ๋ธ/์ปจ์
/ํ์ ๋ณํ ์์ด๋์ด๋ฅผ ์์ฑํ๊ณ , ํด๋น ํ์ฅ ์์ด๋์ด๋ฅผ ํ๋กฌํํธ๋ก ํ์ฌ ๋์์ธ ์ด๋ฏธ์ง๋ฅผ ์์ฑํฉ๋๋ค. https://discord.gg/openfreeai")
|
891 |
+
|
892 |
warning_ko = gr.Markdown(get_warning_message_lang("ko"))
|
893 |
+
|
894 |
with gr.Row():
|
895 |
with gr.Column(scale=1):
|
896 |
text_input1_ko = gr.Textbox(label="ํค์๋ 1 (ํ์)", placeholder="์: ์ค๋งํธํฐ")
|
|
|
903 |
info="์ถ๋ ฅํ ์นดํ
๊ณ ๋ฆฌ๋ฅผ ์ ํํ์ธ์."
|
904 |
)
|
905 |
status_msg_ko = gr.Markdown("๐ก '์์ด๋์ด ์์ฑํ๊ธฐ' ๋ฒํผ์ ํด๋ฆญํ๋ฉด ์ ํํ ์นดํ
๊ณ ๋ฆฌ์ ํด๋นํ๋ ์์ด๋์ด์ ๋์์ธ ์ด๋ฏธ์ง๊ฐ ์์ฑ๋ฉ๋๋ค.")
|
906 |
+
|
907 |
processing_indicator_ko = gr.HTML("""
|
908 |
<div style="display: flex; justify-content: center; align-items: center; margin: 10px 0;">
|
909 |
<div style="border: 5px solid #f3f3f3; border-top: 5px solid #3498db; border-radius: 50%; width: 30px; height: 30px; animation: spin 2s linear infinite;"></div>
|
|
|
916 |
}
|
917 |
</style>
|
918 |
""", visible=False)
|
919 |
+
|
920 |
submit_button_ko = gr.Button("์์ด๋์ด ์์ฑํ๊ธฐ", variant="primary")
|
921 |
+
|
922 |
with gr.Column(scale=2):
|
923 |
idea_output_ko = gr.Markdown(label="์์ด๋์ด ๊ฒฐ๊ณผ")
|
924 |
generated_image_ko = gr.Image(label="์์ฑ๋ ๋์์ธ ์ด๋ฏธ์ง", type="pil")
|
925 |
+
|
926 |
gr.Examples(
|
927 |
examples=[
|
928 |
["์ค๋งํธํฐ", "", "", "์ผ์ ๊ธฐ๋ฅ"],
|
|
|
931 |
["๋๋ก ", "์ธ๊ณต์ง๋ฅ", "", "๋ฌผ์ง์ ์ํ ๋ณํ"],
|
932 |
["์ด๋ํ", "์จ์ด๋ฌ๋ธ", "๊ฑด๊ฐ", "๊ตฌ์กฐ์ ๋ณํ"],
|
933 |
],
|
934 |
+
inputs=[text_input1_ko, text_input2_ko, text_input3_ko, category_radio_ko],
|
935 |
)
|
936 |
+
|
937 |
def show_processing_indicator_ko():
|
938 |
return gr.update(visible=True)
|
939 |
+
|
940 |
def hide_processing_indicator_ko():
|
941 |
return gr.update(visible=False)
|
942 |
+
|
943 |
submit_button_ko.click(
|
944 |
fn=show_processing_indicator_ko,
|
945 |
inputs=None,
|
|
|
955 |
)
|
956 |
|
957 |
if __name__ == "__main__":
|
958 |
+
demo.launch(debug=True)
|