Create model.py
Browse files
model.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from diffusers import DiffusionPipeline
|
2 |
+
import torch
|
3 |
+
|
4 |
+
# Replace with your model path if it's not from the Hugging Face model hub
|
5 |
+
# model_id = "https://api-inference.huggingface.co/models/awabxnero/imagen" # Your Hugging Face model repo
|
6 |
+
pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell")
|
7 |
+
pipe = pipe.to("cuda") # Move model to GPU if available
|
8 |
+
|
9 |
+
# Function to generate image from prompt
|
10 |
+
def generate_image(prompt):
|
11 |
+
# Generate image
|
12 |
+
image = pipe(prompt).images[0]
|
13 |
+
image.show() # Show the image (you can also save or return the image)
|
14 |
+
return image
|
15 |
+
|
16 |
+
if __name__ == "__main__":
|
17 |
+
prompt = "A beautiful sunset over the ocean"
|
18 |
+
generate_image(prompt)
|