Spaces:
Sleeping
Sleeping
Changed on website
Browse files
app.py
CHANGED
|
@@ -1,6 +1,52 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 6 |
-
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from huggingface_hub import InferenceClient
|
| 3 |
+
# import requests
|
| 4 |
+
# import io
|
| 5 |
+
# from PIL import Image
|
| 6 |
+
# needed a change
|
| 7 |
+
|
| 8 |
+
import os
|
| 9 |
+
my_key=(os.getenv('my_write_token'))
|
| 10 |
+
|
| 11 |
+
hf_client = InferenceClient(
|
| 12 |
+
provider="hf-inference",
|
| 13 |
+
api_key=my_key,
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
# output is a PIL.Image object
|
| 17 |
+
def generate_image_model_001(prompt):
|
| 18 |
+
image = hf_client.text_to_image(
|
| 19 |
+
prompt,
|
| 20 |
+
model="stabilityai/stable-diffusion-xl-base-1.0",
|
| 21 |
+
)
|
| 22 |
+
return image
|
| 23 |
+
|
| 24 |
+
# second model definitions here
|
| 25 |
+
|
| 26 |
+
from huggingface_hub import InferenceClient
|
| 27 |
+
|
| 28 |
+
together_client = InferenceClient(
|
| 29 |
+
provider="together",
|
| 30 |
+
api_key=my_key,
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
def generate_image_model_002(prompt):
|
| 34 |
+
image = together_client.text_to_image(
|
| 35 |
+
prompt,
|
| 36 |
+
model="black-forest-labs/FLUX.1-dev",
|
| 37 |
+
)
|
| 38 |
+
return image
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
my_interface=gr.Interface(
|
| 44 |
+
fn=generate_image_model_002,
|
| 45 |
+
inputs=gr.Textbox(label="Enter your prompt"),
|
| 46 |
+
outputs=gr.Image(type="pil", label="Generated Image"),
|
| 47 |
+
title="Stable Diffusion Image Generation",
|
| 48 |
+
description="Generate images from text prompts using Stable Diffusion.",
|
| 49 |
+
)
|
| 50 |
+
|
| 51 |
+
my_interface.launch(share=True)
|
| 52 |
|
|
|
|
|
|