Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,23 +1,15 @@
|
|
| 1 |
import os
|
| 2 |
-
import
|
| 3 |
-
import
|
| 4 |
-
from PIL import Image
|
| 5 |
import gradio as gr
|
|
|
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
-
headers = {
|
| 10 |
-
"Authorization": f"Bearer {os.getenv('secret')}"
|
| 11 |
-
}
|
| 12 |
-
|
| 13 |
-
def query(prompt):
|
| 14 |
-
response = requests.post(API_URL, headers=headers, json={"inputs": prompt})
|
| 15 |
-
response.raise_for_status() # Raise an error for bad responses
|
| 16 |
-
return response.content
|
| 17 |
|
| 18 |
def generate_image(prompt):
|
| 19 |
-
|
| 20 |
-
image =
|
| 21 |
return image
|
| 22 |
|
| 23 |
# Gradio interface
|
|
|
|
| 1 |
import os
|
| 2 |
+
import torch
|
| 3 |
+
from diffusers import DiffusionPipeline
|
|
|
|
| 4 |
import gradio as gr
|
| 5 |
+
from PIL import Image
|
| 6 |
|
| 7 |
+
# Load the model
|
| 8 |
+
pipeline = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-dev").to("cuda" if torch.cuda.is_available() else "cpu")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
def generate_image(prompt):
|
| 11 |
+
# Generate the image using the pipeline
|
| 12 |
+
image = pipeline(prompt).images[0]
|
| 13 |
return image
|
| 14 |
|
| 15 |
# Gradio interface
|