Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import torch
|
2 |
from diffusers import DiffusionPipeline
|
3 |
import gradio as gr
|
@@ -8,14 +9,14 @@ def load_pipeline():
|
|
8 |
lora_repo = "strangerzonehf/Flux-Super-Realism-LoRA"
|
9 |
trigger_word = "Super Realism" # Recommended trigger word
|
10 |
|
11 |
-
# Retrieve your Hugging Face token from an environment variable
|
12 |
-
hf_token = os.environ.get("HF_TOKEN")
|
13 |
|
14 |
-
pipe = DiffusionPipeline.from_pretrained(
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
)
|
19 |
|
20 |
# Load the LoRA weights into the pipeline
|
21 |
pipe.load_lora_weights(lora_repo)
|
@@ -52,7 +53,11 @@ def generate_image(prompt, seed, width, height, guidance_scale, randomize_seed):
|
|
52 |
iface = gr.Interface(
|
53 |
fn=generate_image,
|
54 |
inputs=[
|
55 |
-
gr.inputs.Textbox(
|
|
|
|
|
|
|
|
|
56 |
gr.inputs.Slider(0, 10000, step=1, default=0, label="Seed (0 for random)"),
|
57 |
gr.inputs.Slider(256, 1024, step=64, default=1024, label="Width"),
|
58 |
gr.inputs.Slider(256, 1024, step=64, default=1024, label="Height"),
|
@@ -69,4 +74,4 @@ iface = gr.Interface(
|
|
69 |
)
|
70 |
|
71 |
if __name__ == "__main__":
|
72 |
-
|
|
|
1 |
+
import os
|
2 |
import torch
|
3 |
from diffusers import DiffusionPipeline
|
4 |
import gradio as gr
|
|
|
9 |
lora_repo = "strangerzonehf/Flux-Super-Realism-LoRA"
|
10 |
trigger_word = "Super Realism" # Recommended trigger word
|
11 |
|
12 |
+
# Retrieve your Hugging Face token from an environment variable
|
13 |
+
hf_token = os.environ.get("HF_TOKEN")
|
14 |
|
15 |
+
pipe = DiffusionPipeline.from_pretrained(
|
16 |
+
base_model,
|
17 |
+
torch_dtype=torch.bfloat16,
|
18 |
+
use_auth_token=hf_token # Use the token stored in your environment variable
|
19 |
+
)
|
20 |
|
21 |
# Load the LoRA weights into the pipeline
|
22 |
pipe.load_lora_weights(lora_repo)
|
|
|
53 |
iface = gr.Interface(
|
54 |
fn=generate_image,
|
55 |
inputs=[
|
56 |
+
gr.inputs.Textbox(
|
57 |
+
lines=2,
|
58 |
+
label="Prompt",
|
59 |
+
placeholder="Enter your prompt, e.g., 'A tiny astronaut hatching from an egg on the moon, 4k, planet theme'"
|
60 |
+
),
|
61 |
gr.inputs.Slider(0, 10000, step=1, default=0, label="Seed (0 for random)"),
|
62 |
gr.inputs.Slider(256, 1024, step=64, default=1024, label="Width"),
|
63 |
gr.inputs.Slider(256, 1024, step=64, default=1024, label="Height"),
|
|
|
74 |
)
|
75 |
|
76 |
if __name__ == "__main__":
|
77 |
+
iface.launch(share=True)
|