SNA-AI commited on
Commit
cd3ab0c
ยท
verified ยท
1 Parent(s): 7e14cc3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -36
app.py CHANGED
@@ -1,43 +1,50 @@
1
- import gradio as gr
2
- import os
3
- from huggingface_hub import InferenceClient
4
-
5
- # ๐Ÿ”‘ load secret
6
- HF_TOKEN = os.getenv("image")
7
-
8
- def debug():
9
- return f"DEBUG - TOKEN LOADED: {HF_TOKEN is not None}"
10
-
11
- client = None
12
- if HF_TOKEN:
13
- client = InferenceClient(
14
- model="stabilityai/stable-diffusion-xl-base-1.0",
15
- token=HF_TOKEN
 
 
 
 
 
 
 
 
 
 
 
16
  )
17
 
18
- def generate_image(prompt):
19
- if not prompt.strip():
20
- return None, "โš ๏ธ Enter prompt"
21
-
22
- if client is None:
23
- return None, "โŒ TOKEN STILL NOT LOADED (check secrets + restart)"
24
-
25
- image = client.text_to_image(prompt)
26
- return image, "โœ… Success"
27
-
28
-
29
- with gr.Blocks() as app:
30
- gr.Markdown("# ๐ŸŽจ DEBUG IMAGE GENERATOR")
31
-
32
- gr.Textbox(value=debug(), label="System Status")
33
 
34
- prompt = gr.Textbox(label="Prompt")
 
 
35
 
36
- btn = gr.Button("Generate")
 
 
37
 
38
- img = gr.Image(type="pil")
39
- status = gr.Textbox()
40
 
41
- btn.click(generate_image, prompt, [img, status])
42
 
43
- app.launch()
 
 
1
+ with gr.Blocks(
2
+ theme=gr.themes.Soft(
3
+ primary_hue="blue",
4
+ secondary_hue="indigo",
5
+ neutral_hue="gray"
6
+ ),
7
+ css="""
8
+ body {
9
+ background-color: #f4f7ff !important;
10
+ }
11
+
12
+ .gradio-container {
13
+ background-color: #f4f7ff !important;
14
+ }
15
+
16
+ button {
17
+ border-radius: 10px !important;
18
+ }
19
+ """
20
+ ) as app:
21
+
22
+ gr.Markdown(
23
+ """
24
+ # ๐ŸŽจ AI Text โ†’ Image Generator
25
+ ### โœจ Create beautiful AI images instantly
26
+ """
27
  )
28
 
29
+ with gr.Row():
30
+ prompt = gr.Textbox(
31
+ label="โœ๏ธ Enter Prompt",
32
+ placeholder="A futuristic city at sunset, ultra detailed, cinematic lighting",
33
+ lines=3
34
+ )
 
 
 
 
 
 
 
 
 
35
 
36
+ with gr.Row():
37
+ width = gr.Slider(256, 1024, value=768, step=64, label="๐Ÿ“ Width")
38
+ height = gr.Slider(256, 1024, value=768, step=64, label="๐Ÿ“ Height")
39
 
40
+ with gr.Row():
41
+ generate_btn = gr.Button("๐Ÿš€ Generate Image", variant="primary")
42
+ clear_btn = gr.Button("๐Ÿงน Clear")
43
 
44
+ output_image = gr.Image(label="๐Ÿ–ผ๏ธ Generated Image", type="pil")
45
+ status = gr.Textbox(label="๐Ÿ“ข Status")
46
 
47
+ generate_btn.click(generate_image, [prompt, width, height], [output_image, status])
48
 
49
+ clear_btn.click(lambda: ("", 768, 768, None, ""), None,
50
+ [prompt, width, height, output_image, status])