title
Browse files
app.py
CHANGED
@@ -6,10 +6,8 @@ import gradio as gr
|
|
6 |
import numpy as np
|
7 |
import requests
|
8 |
from dotenv import load_dotenv
|
9 |
-
|
10 |
from huggingface_hub import InferenceClient
|
11 |
|
12 |
-
|
13 |
FAL_KEY = os.environ.get("FAL_KEY") # Load FAL_KEY
|
14 |
|
15 |
|
@@ -104,7 +102,7 @@ def set_fal_key(fal_key_from_ui: str | None):
|
|
104 |
gr.Info("FAL_KEY is configured.")
|
105 |
|
106 |
|
107 |
-
def
|
108 |
"""
|
109 |
Generate an image from a prompt.
|
110 |
Args:
|
@@ -226,7 +224,7 @@ with gr.Blocks(css=css) as demo:
|
|
226 |
with gr.Sidebar():
|
227 |
gr.Markdown("# Authentication")
|
228 |
gr.Markdown(
|
229 |
-
"Sign in with Hugging Face for image generation. Separately, set your FAL_KEY for video generation."
|
230 |
)
|
231 |
|
232 |
gr.Markdown("### Hugging Face Login")
|
@@ -246,7 +244,8 @@ with gr.Blocks(css=css) as demo:
|
|
246 |
|
247 |
with gr.Column(elem_id="col-container"):
|
248 |
gr.Markdown(
|
249 |
-
"""#
|
|
|
250 |
)
|
251 |
|
252 |
with gr.Row():
|
@@ -302,7 +301,7 @@ with gr.Blocks(css=css) as demo:
|
|
302 |
|
303 |
gr.Examples(
|
304 |
examples=examples,
|
305 |
-
fn=
|
306 |
inputs=[prompt],
|
307 |
outputs=[result, seed_number],
|
308 |
cache_examples="lazy",
|
@@ -318,7 +317,7 @@ with gr.Blocks(css=css) as demo:
|
|
318 |
}
|
319 |
|
320 |
run_button.click(
|
321 |
-
fn=
|
322 |
inputs=[prompt, seed_slider, width_slider, height_slider, steps_slider],
|
323 |
outputs=[result, seed_number],
|
324 |
).then(
|
@@ -372,7 +371,7 @@ with gr.Blocks(css=css) as demo:
|
|
372 |
)
|
373 |
|
374 |
run_button.click(
|
375 |
-
fn=
|
376 |
inputs=[prompt, seed_slider, width_slider, height_slider, steps_slider],
|
377 |
outputs=[result, seed_number],
|
378 |
).then(
|
|
|
6 |
import numpy as np
|
7 |
import requests
|
8 |
from dotenv import load_dotenv
|
|
|
9 |
from huggingface_hub import InferenceClient
|
10 |
|
|
|
11 |
FAL_KEY = os.environ.get("FAL_KEY") # Load FAL_KEY
|
12 |
|
13 |
|
|
|
102 |
gr.Info("FAL_KEY is configured.")
|
103 |
|
104 |
|
105 |
+
def generate_image(prompt: str, seed: int = 42, width: int = 1024, height: int = 1024, num_inference_steps: int = 25):
|
106 |
"""
|
107 |
Generate an image from a prompt.
|
108 |
Args:
|
|
|
224 |
with gr.Sidebar():
|
225 |
gr.Markdown("# Authentication")
|
226 |
gr.Markdown(
|
227 |
+
"Sign in with Hugging Face for image generation. Separately, set your FAL_KEY for image to video generation."
|
228 |
)
|
229 |
|
230 |
gr.Markdown("### Hugging Face Login")
|
|
|
244 |
|
245 |
with gr.Column(elem_id="col-container"):
|
246 |
gr.Markdown(
|
247 |
+
"""# Text to Image to Video with fal‑ai through HF Inference Providers ⚡\nLearn more about HF Inference Providers [here](https://huggingface.co/docs/inference-providers/index)"""
|
248 |
+
"""Text to Image uses FLUX.1 [dev] with fal‑ai through HF Inference Providers, Video Generation uses kling-video/v2.1/master/image-to-video with fal‑ai directly (you will need to set your FAL_KEY)."""
|
249 |
)
|
250 |
|
251 |
with gr.Row():
|
|
|
301 |
|
302 |
gr.Examples(
|
303 |
examples=examples,
|
304 |
+
fn=generate_image,
|
305 |
inputs=[prompt],
|
306 |
outputs=[result, seed_number],
|
307 |
cache_examples="lazy",
|
|
|
317 |
}
|
318 |
|
319 |
run_button.click(
|
320 |
+
fn=generate_image,
|
321 |
inputs=[prompt, seed_slider, width_slider, height_slider, steps_slider],
|
322 |
outputs=[result, seed_number],
|
323 |
).then(
|
|
|
371 |
)
|
372 |
|
373 |
run_button.click(
|
374 |
+
fn=generate_image,
|
375 |
inputs=[prompt, seed_slider, width_slider, height_slider, steps_slider],
|
376 |
outputs=[result, seed_number],
|
377 |
).then(
|