Mehak-Mazhar commited on
Commit
24b81db
·
verified ·
1 Parent(s): cdec560

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -4
app.py CHANGED
@@ -1,4 +1,16 @@
1
  # -*- coding: utf-8 -*-
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  import os
4
  import io
@@ -76,9 +88,21 @@ with gr.Blocks(css=css, title="Flux Text→Image — designed by Mehak Mazhar")
76
 
77
  with gr.Row():
78
  with gr.Column(scale=1, min_width=360):
79
- prompt = gr.Textbox(label="Prompt", placeholder="A serene mountain lake at sunset, digital painting, ultra-detailed", rows=4)
80
- negative = gr.Textbox(label="Negative prompt (optional)", placeholder="blurry, lowres, text, watermark", rows=2)
81
- hf_token = gr.Textbox(label="Hugging Face API Token (optional)", placeholder="Paste your HF token here or set HF_TOKEN env var", type="password")
 
 
 
 
 
 
 
 
 
 
 
 
82
  with gr.Row():
83
  width = gr.Dropdown(choices=[256,384,512,768,1024], value=512, label="Width")
84
  height = gr.Dropdown(choices=[256,384,512,768,1024], value=512, label="Height")
@@ -88,7 +112,7 @@ with gr.Blocks(css=css, title="Flux Text→Image — designed by Mehak Mazhar")
88
  with gr.Row():
89
  seed = gr.Number(value=None, precision=0, label="Seed (leave blank for random)")
90
  gen_btn = gr.Button("Generate", elem_classes="generator-btn")
91
- info = gr.Markdown("**Tip:** Use vivid, descriptive prompts. Try styles like `cinematic lighting`, `digital oil painting`, or `ultra-detailed`.")
92
 
93
  with gr.Column(scale=1, min_width=360):
94
  gallery = gr.Gallery(label="Generated images", show_label=True, elem_id="gallery").style(grid=[2], height="640px")
 
1
  # -*- coding: utf-8 -*-
2
+ """
3
+ Gradio Space: Text → Image using FLUX.1 (Hugging Face Inference API)
4
+ Attractive interface with custom styling and footer label: "designed by Mehak Mazhar"
5
+
6
+ How to use:
7
+ 1. Install dependencies: pip install gradio requests pillow
8
+ 2. Get a Hugging Face API token (if you want to use the hosted FLUX.1 models) and either set it as an env var HF_TOKEN or paste it into the 'HF Token' field in the UI.
9
+ 3. Run: python app.py
10
+
11
+ Notes: this script calls the Hugging Face Inference API for the model 'black-forest-labs/FLUX.1-schnell' by default.
12
+ You can change the MODEL variable to any compatible image generation model hosted on Hugging Face or point to your own inference server.
13
+ """
14
 
15
  import os
16
  import io
 
88
 
89
  with gr.Row():
90
  with gr.Column(scale=1, min_width=360):
91
+ prompt = gr.Textbox(
92
+ label="Prompt",
93
+ placeholder="A serene mountain lake at sunset, digital painting, ultra-detailed",
94
+ lines=4
95
+ )
96
+ negative = gr.Textbox(
97
+ label="Negative prompt (optional)",
98
+ placeholder="blurry, lowres, text, watermark",
99
+ lines=2
100
+ )
101
+ hf_token = gr.Textbox(
102
+ label="Hugging Face API Token (optional)",
103
+ placeholder="Paste your HF token here or set HF_TOKEN env var",
104
+ type="password"
105
+ )
106
  with gr.Row():
107
  width = gr.Dropdown(choices=[256,384,512,768,1024], value=512, label="Width")
108
  height = gr.Dropdown(choices=[256,384,512,768,1024], value=512, label="Height")
 
112
  with gr.Row():
113
  seed = gr.Number(value=None, precision=0, label="Seed (leave blank for random)")
114
  gen_btn = gr.Button("Generate", elem_classes="generator-btn")
115
+ gr.Markdown("**Tip:** Use vivid, descriptive prompts. Try styles like `cinematic lighting`, `digital oil painting`, or `ultra-detailed`.")
116
 
117
  with gr.Column(scale=1, min_width=360):
118
  gallery = gr.Gallery(label="Generated images", show_label=True, elem_id="gallery").style(grid=[2], height="640px")