Spaces:
Running
Running
test
Browse files
app.py
CHANGED
|
@@ -1,7 +1,36 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
def
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 7 |
demo.launch()
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from gradio_client import Client, handle_file
|
| 3 |
|
| 4 |
+
def text_to_image(prompt, image, request: gr.Request):
|
| 5 |
+
x_ip_token = request.headers['x-ip-token']
|
| 6 |
+
print(x_ip_token)
|
| 7 |
+
client = Client("black-forest-labs/FLUX.1-Kontext-Dev", headers={"x-ip-token": x_ip_token})
|
| 8 |
+
result = client.predict(
|
| 9 |
+
input_image=handle_file(image),
|
| 10 |
+
prompt=prompt,
|
| 11 |
+
seed=0,
|
| 12 |
+
randomize_seed=True,
|
| 13 |
+
guidance_scale=2.5,
|
| 14 |
+
steps=30,
|
| 15 |
+
api_name="/infer"
|
| 16 |
+
)
|
| 17 |
+
print(result)
|
| 18 |
+
return result
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
with gr.Blocks() as demo:
|
| 22 |
+
image = gr.Image()
|
| 23 |
+
input_image = gr.Image(type="filepath")
|
| 24 |
+
prompt = gr.Textbox(max_lines=1)
|
| 25 |
+
prompt.submit(text_to_image, [prompt, input_image], [image])
|
| 26 |
+
|
| 27 |
+
gr.Examples(
|
| 28 |
+
examples=[
|
| 29 |
+
["A sunny day", "https://black-forest-labs-flux-1-kontext-dev.hf.space/gradio_api/file=/tmp/gradio/927b05b08b8ec2201f7d95722471d2089d4197f152c9c07d0bc9f9672962d03b/flowers.png"],
|
| 30 |
+
],
|
| 31 |
+
inputs=[prompt, input_image],
|
| 32 |
+
outputs=image,
|
| 33 |
+
)
|
| 34 |
|
|
|
|
| 35 |
demo.launch()
|
| 36 |
+
|