add flux
Browse files
app.py
CHANGED
@@ -6,13 +6,23 @@ import random
|
|
6 |
import time
|
7 |
from diffusers import AutoPipelineForText2Image
|
8 |
from diffusers import AutoPipelineForImage2Image
|
|
|
9 |
from diffusers.utils import load_image
|
10 |
pipeline_text2image = AutoPipelineForText2Image.from_pretrained("stabilityai/sdxl-turbo").to("cuda")
|
11 |
pipeline_image2image = AutoPipelineForImage2Image.from_pipe(pipeline_text2image).to("cuda")
|
|
|
12 |
|
13 |
-
def text2img(prompt = "A cinematic shot of a baby racoon wearing an intricate italian priest robe.",guidance_scale=0.0, num_inference_steps=1):
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
return image
|
17 |
|
18 |
def img2img(image,prompt="A cinematic shot of a baby racoon wearing an intricate italian priest robe.", guidance_scale=0.0, num_inference_steps=1,strength=0.5):
|
@@ -26,6 +36,9 @@ gradio_app_text2img = gr.Interface(
|
|
26 |
fn=text2img,
|
27 |
inputs=[
|
28 |
gr.Text(),
|
|
|
|
|
|
|
29 |
gr.Slider(0.0, 2.0, value=1,step=0.1),
|
30 |
gr.Slider(2.0, 20.0, value=1,step=1)
|
31 |
],
|
|
|
6 |
import time
|
7 |
from diffusers import AutoPipelineForText2Image
|
8 |
from diffusers import AutoPipelineForImage2Image
|
9 |
+
from diffusers import FluxPipeline
|
10 |
from diffusers.utils import load_image
|
11 |
pipeline_text2image = AutoPipelineForText2Image.from_pretrained("stabilityai/sdxl-turbo").to("cuda")
|
12 |
pipeline_image2image = AutoPipelineForImage2Image.from_pipe(pipeline_text2image).to("cuda")
|
13 |
+
pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16).to("cuda")
|
14 |
|
15 |
+
def text2img(prompt = "A cinematic shot of a baby racoon wearing an intricate italian priest robe.",model="flux",guidance_scale=0.0, num_inference_steps=1):
|
16 |
+
if model=="flux":
|
17 |
+
image = pipe(
|
18 |
+
prompt,
|
19 |
+
guidance_scale=guidance_scale,
|
20 |
+
num_inference_steps=num_inference_steps,
|
21 |
+
max_sequence_length=256,
|
22 |
+
generator=torch.Generator("cpu").manual_seed(0)
|
23 |
+
).images[0]
|
24 |
+
else:
|
25 |
+
image = pipeline_text2image(prompt=prompt, guidance_scale=guidance_scale, num_inference_steps=num_inference_steps).images[0]
|
26 |
return image
|
27 |
|
28 |
def img2img(image,prompt="A cinematic shot of a baby racoon wearing an intricate italian priest robe.", guidance_scale=0.0, num_inference_steps=1,strength=0.5):
|
|
|
36 |
fn=text2img,
|
37 |
inputs=[
|
38 |
gr.Text(),
|
39 |
+
gr.Dropdown(
|
40 |
+
["flux", "stable diffusion"], label="model", info="model to use"
|
41 |
+
),
|
42 |
gr.Slider(0.0, 2.0, value=1,step=0.1),
|
43 |
gr.Slider(2.0, 20.0, value=1,step=1)
|
44 |
],
|