Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,6 +5,8 @@ import os
|
|
| 5 |
from datetime import datetime
|
| 6 |
import random
|
| 7 |
from transformers import pipeline
|
|
|
|
|
|
|
| 8 |
|
| 9 |
#----------Start of theme----------
|
| 10 |
theme = gr.themes.Soft(
|
|
@@ -291,12 +293,39 @@ css = """
|
|
| 291 |
with gr.Blocks(theme=theme, css=css) as app:
|
| 292 |
gr.HTML("<center><h6>🎨 Image Studio</h6></center>")
|
| 293 |
with gr.Tab("Text to Image"):
|
| 294 |
-
|
| 295 |
#gr.HTML("<center><b>Flux</b></center>")
|
| 296 |
#gr.load("models/XLabs-AI/flux-RealismLora")
|
| 297 |
#gr.load("models/digiplay/AnalogMadness-realistic-model-v7")
|
| 298 |
#gr.load("stabilityai/stable-diffusion-3-medium-diffusers")
|
| 299 |
-
model=gr.load("models/dvyio/flux-lora-film-noir")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 300 |
|
| 301 |
|
| 302 |
with gr.Tab("Flip Image"):
|
|
|
|
| 5 |
from datetime import datetime
|
| 6 |
import random
|
| 7 |
from transformers import pipeline
|
| 8 |
+
import torch
|
| 9 |
+
from diffusers import FluxPipeline
|
| 10 |
|
| 11 |
#----------Start of theme----------
|
| 12 |
theme = gr.themes.Soft(
|
|
|
|
| 293 |
with gr.Blocks(theme=theme, css=css) as app:
|
| 294 |
gr.HTML("<center><h6>🎨 Image Studio</h6></center>")
|
| 295 |
with gr.Tab("Text to Image"):
|
|
|
|
| 296 |
#gr.HTML("<center><b>Flux</b></center>")
|
| 297 |
#gr.load("models/XLabs-AI/flux-RealismLora")
|
| 298 |
#gr.load("models/digiplay/AnalogMadness-realistic-model-v7")
|
| 299 |
#gr.load("stabilityai/stable-diffusion-3-medium-diffusers")
|
| 300 |
+
#model=gr.load("models/dvyio/flux-lora-film-noir")
|
| 301 |
+
base_model_id = "Freepik/flux.1-lite-8B-alpha"
|
| 302 |
+
torch_dtype = torch.bfloat16
|
| 303 |
+
device = "cuda"
|
| 304 |
+
|
| 305 |
+
# Load the pipe
|
| 306 |
+
model_id = "Freepik/flux.1-lite-8B-alpha"
|
| 307 |
+
pipe = FluxPipeline.from_pretrained(
|
| 308 |
+
model_id, torch_dtype=torch_dtype
|
| 309 |
+
).to(device)
|
| 310 |
+
|
| 311 |
+
# Inference
|
| 312 |
+
prompt = "A close-up image of a green alien with fluorescent skin in the middle of a dark purple forest"
|
| 313 |
+
|
| 314 |
+
guidance_scale = 3.5 # Keep guidance_scale at 3.5
|
| 315 |
+
n_steps = 28
|
| 316 |
+
seed = 11
|
| 317 |
+
|
| 318 |
+
with torch.inference_mode():
|
| 319 |
+
image = pipe(
|
| 320 |
+
prompt=prompt,
|
| 321 |
+
generator=torch.Generator(device="cpu").manual_seed(seed),
|
| 322 |
+
num_inference_steps=n_steps,
|
| 323 |
+
guidance_scale=guidance_scale,
|
| 324 |
+
height=1024,
|
| 325 |
+
width=1024,
|
| 326 |
+
).images[0]
|
| 327 |
+
image.save("output.png")
|
| 328 |
+
|
| 329 |
|
| 330 |
|
| 331 |
with gr.Tab("Flip Image"):
|