Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,6 +2,20 @@ import gradio as gr
|
|
| 2 |
from diffusers import DiffusionPipeline
|
| 3 |
import torch
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
# Load the FLUX.1-dev model from Hugging Face
|
| 6 |
pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.float16)
|
| 7 |
pipe = pipe.to("cuda")
|
|
|
|
| 2 |
from diffusers import DiffusionPipeline
|
| 3 |
import torch
|
| 4 |
|
| 5 |
+
import requests
|
| 6 |
+
|
| 7 |
+
API_URL = "https://router.huggingface.co/hf-inference/v1"
|
| 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 |
+
# 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)
|
| 21 |
pipe = pipe.to("cuda")
|