Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,13 +8,8 @@ API_URL = "https://router.huggingface.co/hf-inference/v1"
|
|
8 |
headers = {"Authorization": "Bearer hf_xxxxxxxxxxxxxxxxxxxxxxxx"}
|
9 |
|
10 |
def query(payload):
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
# You can access the image with PIL.Image for example
|
15 |
-
import io
|
16 |
-
from PIL import Image
|
17 |
-
image = Image.open(io.BytesIO(image_bytes))
|
18 |
|
19 |
# Load the FLUX.1-dev model from Hugging Face
|
20 |
pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.float16)
|
@@ -22,6 +17,7 @@ pipe = pipe.to("cuda")
|
|
22 |
|
23 |
# Define a function to generate an image based on the prompt
|
24 |
def generate_image(prompt: str):
|
|
|
25 |
image = pipe(prompt).images[0]
|
26 |
return image
|
27 |
|
@@ -34,3 +30,4 @@ iface = gr.Interface(fn=generate_image,
|
|
34 |
|
35 |
# Launch the app
|
36 |
iface.launch()
|
|
|
|
8 |
headers = {"Authorization": "Bearer hf_xxxxxxxxxxxxxxxxxxxxxxxx"}
|
9 |
|
10 |
def query(payload):
|
11 |
+
response = requests.post(API_URL, headers=headers, json=payload)
|
12 |
+
return response.content
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
# Load the FLUX.1-dev model from Hugging Face
|
15 |
pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.float16)
|
|
|
17 |
|
18 |
# Define a function to generate an image based on the prompt
|
19 |
def generate_image(prompt: str):
|
20 |
+
# Generate the image using the pipeline
|
21 |
image = pipe(prompt).images[0]
|
22 |
return image
|
23 |
|
|
|
30 |
|
31 |
# Launch the app
|
32 |
iface.launch()
|
33 |
+
|