akhaliq HF Staff commited on
Commit
f05400f
·
verified ·
1 Parent(s): 3f6c6eb

Update Gradio app with multiple files

Browse files
Files changed (3) hide show
  1. app.py +4 -6
  2. config.py +21 -0
  3. models.py +0 -2
app.py CHANGED
@@ -1,8 +1,9 @@
1
  import gradio as gr
2
  from models import generate_image, MODEL_ID
 
3
 
4
  def create_ui():
5
- with gr.Blocks(title=f"Tencent HunyuanImage-3.0 Demo") as demo:
6
  gr.HTML(
7
  f"<div style='text-align: center; max-width: 700px; margin: 0 auto;'>"
8
  f"<h1>Tencent {MODEL_ID.split('/')[-1]}</h1>"
@@ -15,7 +16,7 @@ def create_ui():
15
  with gr.Column(scale=1):
16
  prompt_input = gr.Textbox(
17
  label="Prompt",
18
- placeholder="e.g., Astronaut riding a horse, 4K, realistic photo, cinematic lighting",
19
  lines=4
20
  )
21
  generate_btn = gr.Button("🎨 Generate Image", variant="primary")
@@ -34,15 +35,12 @@ def create_ui():
34
  fn=generate_image,
35
  inputs=[prompt_input],
36
  outputs=[output_image],
37
- # Use queue and concurrency for robustness when dealing with external APIs
38
  queue=True
39
  )
40
 
41
- # Example usage guidance
42
  gr.Examples(
43
  examples=[
44
- "A dramatic black and white photo of a futuristic motorcycle gang leader in a rainy city street.",
45
- "High quality photorealistic close-up portrait of an elderly wizard, highly detailed, dramatic lighting.",
46
  "A detailed watercolor painting of a small red fox sleeping on a pile of autumn leaves."
47
  ],
48
  inputs=prompt_input,
 
1
  import gradio as gr
2
  from models import generate_image, MODEL_ID
3
+ from config import APPLE_TENCENT_THEME
4
 
5
  def create_ui():
6
+ with gr.Blocks(title=f"Tencent HunyuanImage-3.0 Demo", theme=APPLE_TENCENT_THEME) as demo:
7
  gr.HTML(
8
  f"<div style='text-align: center; max-width: 700px; margin: 0 auto;'>"
9
  f"<h1>Tencent {MODEL_ID.split('/')[-1]}</h1>"
 
16
  with gr.Column(scale=1):
17
  prompt_input = gr.Textbox(
18
  label="Prompt",
19
+ placeholder="e.g., A detailed watercolor painting of a small red fox sleeping on a pile of autumn leaves.",
20
  lines=4
21
  )
22
  generate_btn = gr.Button("🎨 Generate Image", variant="primary")
 
35
  fn=generate_image,
36
  inputs=[prompt_input],
37
  outputs=[output_image],
 
38
  queue=True
39
  )
40
 
41
+ # Example usage guidance - only the Fox example is kept
42
  gr.Examples(
43
  examples=[
 
 
44
  "A detailed watercolor painting of a small red fox sleeping on a pile of autumn leaves."
45
  ],
46
  inputs=prompt_input,
config.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ # Define a custom theme based on Soft theme for a modern/Apple aesthetic
4
+ # Using Indigo for a deep tech blue (Tencent blue approximation)
5
+ APPLE_TENCENT_THEME = gr.themes.Soft(
6
+ primary_hue=gr.themes.colors.Indigo, # Deep tech blue
7
+ secondary_hue=gr.themes.colors.Gray,
8
+ neutral_hue=gr.themes.colors.Neutral,
9
+ spacing_size=gr.themes.sizes.spacing_lg,
10
+ radius_size=gr.themes.sizes.radius_lg,
11
+ text_size=gr.themes.sizes.text_md,
12
+ ).set(
13
+ # Custom tweaks for a cleaner, high-contrast look
14
+ body_background_fill="#F9F9F9",
15
+ background_fill_primary="#FFFFFF",
16
+ background_fill_secondary="#F0F0F0",
17
+ shadow_drop="0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px 0 rgba(0, 0, 0, 0.02)",
18
+ shadow_drop_lg="0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",
19
+ button_primary_background_fill="*primary_500",
20
+ button_primary_background_fill_hover="*primary_600",
21
+ )
models.py CHANGED
@@ -48,8 +48,6 @@ def generate_image(prompt: str) -> Image.Image:
48
  image = CLIENT.text_to_image(
49
  prompt,
50
  model=MODEL_ID,
51
- # Optional parameters for better quality/control might be added here
52
- # e.g., negative_prompt="bad quality, low resolution",
53
  )
54
  return image
55
  except Exception as e:
 
48
  image = CLIENT.text_to_image(
49
  prompt,
50
  model=MODEL_ID,
 
 
51
  )
52
  return image
53
  except Exception as e: