Spaces:
Running
Running
add scale slider
Browse files- README.md +1 -0
- myapp/app.py +9 -13
README.md
CHANGED
@@ -7,6 +7,7 @@ sdk: gradio
|
|
7 |
sdk_version: 5.12.0
|
8 |
app_file: myapp/app.py
|
9 |
pinned: false
|
|
|
10 |
---
|
11 |
|
12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
7 |
sdk_version: 5.12.0
|
8 |
app_file: myapp/app.py
|
9 |
pinned: false
|
10 |
+
header: mini
|
11 |
---
|
12 |
|
13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
myapp/app.py
CHANGED
@@ -15,7 +15,7 @@ if gr.NO_RELOAD:
|
|
15 |
except ImportError:
|
16 |
pass
|
17 |
|
18 |
-
client = InferenceClient()
|
19 |
|
20 |
with gr.Blocks() as demo:
|
21 |
with gr.Row():
|
@@ -23,10 +23,11 @@ with gr.Blocks() as demo:
|
|
23 |
text = gr.Textbox(
|
24 |
"https://wheelingvultures.bandcamp.com/album/ep", label="Text"
|
25 |
)
|
26 |
-
prompt = gr.
|
27 |
-
button = gr.Button()
|
28 |
with gr.Column():
|
29 |
background = gr.Image(visible=False, type="filepath")
|
|
|
30 |
output = gr.Image()
|
31 |
|
32 |
@gr.on(
|
@@ -35,19 +36,14 @@ with gr.Blocks() as demo:
|
|
35 |
outputs=background,
|
36 |
)
|
37 |
def generate_background(prompt):
|
38 |
-
return client.text_to_image(
|
39 |
-
prompt,
|
40 |
-
model="black-forest-labs/FLUX.1-schnell",
|
41 |
-
width=400,
|
42 |
-
height=400,
|
43 |
-
)
|
44 |
|
45 |
@gr.on(
|
46 |
-
triggers=[
|
47 |
-
inputs=[text, background],
|
48 |
outputs=output,
|
49 |
)
|
50 |
-
def generate_code(text, background):
|
51 |
if background is None:
|
52 |
return None
|
53 |
|
@@ -59,7 +55,7 @@ with gr.Blocks() as demo:
|
|
59 |
qr_code,
|
60 |
background=background,
|
61 |
target=temp_file,
|
62 |
-
scale=
|
63 |
)
|
64 |
|
65 |
return Image.open(temp_file.name)
|
|
|
15 |
except ImportError:
|
16 |
pass
|
17 |
|
18 |
+
client = InferenceClient(model="black-forest-labs/FLUX.1-schnell")
|
19 |
|
20 |
with gr.Blocks() as demo:
|
21 |
with gr.Row():
|
|
|
23 |
text = gr.Textbox(
|
24 |
"https://wheelingvultures.bandcamp.com/album/ep", label="Text"
|
25 |
)
|
26 |
+
prompt = gr.TextArea("A vulture in black and white", label="Prompt")
|
27 |
+
button = gr.Button("Generate")
|
28 |
with gr.Column():
|
29 |
background = gr.Image(visible=False, type="filepath")
|
30 |
+
scale = gr.Slider(3, 15, 9, step=1, label="Scale")
|
31 |
output = gr.Image()
|
32 |
|
33 |
@gr.on(
|
|
|
36 |
outputs=background,
|
37 |
)
|
38 |
def generate_background(prompt):
|
39 |
+
return client.text_to_image(prompt, width=400, height=400)
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
@gr.on(
|
42 |
+
triggers=[text.submit, scale.change, background.change],
|
43 |
+
inputs=[text, scale, background],
|
44 |
outputs=output,
|
45 |
)
|
46 |
+
def generate_code(text, scale, background):
|
47 |
if background is None:
|
48 |
return None
|
49 |
|
|
|
55 |
qr_code,
|
56 |
background=background,
|
57 |
target=temp_file,
|
58 |
+
scale=scale,
|
59 |
)
|
60 |
|
61 |
return Image.open(temp_file.name)
|