Update app.py
Browse files
app.py
CHANGED
|
@@ -10,7 +10,6 @@ import json
|
|
| 10 |
import os
|
| 11 |
|
| 12 |
from diffusers import DiffusionPipeline
|
| 13 |
-
from huggingface_hub import snapshot_download
|
| 14 |
from transformers import pipeline
|
| 15 |
from peft import PeftModel
|
| 16 |
from PIL import Image
|
|
@@ -45,14 +44,14 @@ repo_nsfw_classifier = pipeline("image-classification", model="Falconsai/nsfw_im
|
|
| 45 |
|
| 46 |
repo_default = DiffusionPipeline.from_pretrained("fluently/Fluently-XL-Final", device=DEVICE, torch_dtype=torch.float16, use_safetensors=True, add_watermarker=False)
|
| 47 |
|
| 48 |
-
# repo_large = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-dev",
|
| 49 |
# repo_large.load_lora_weights("ehristoforu/dalle-3-xl-v2", adapter_name="base")
|
| 50 |
# repo_large.set_adapters(["base"], adapter_weights=[0.7])
|
| 51 |
|
| 52 |
repo_customs = {
|
| 53 |
"Default": repo_default,
|
| 54 |
-
"Realistic": DiffusionPipeline.from_pretrained("ehristoforu/Visionix-alpha",
|
| 55 |
-
"Anime": DiffusionPipeline.from_pretrained("cagliostrolab/animagine-xl-3.1",
|
| 56 |
"Pixel": repo_default,
|
| 57 |
# "Large": repo_neo,
|
| 58 |
}
|
|
@@ -73,7 +72,7 @@ def get_seed(seed):
|
|
| 73 |
@spaces.GPU(duration=60)
|
| 74 |
def generate(input=DEFAULT_INPUT, filter_input="", negative_input=DEFAULT_NEGATIVE_INPUT, model=DEFAULT_MODEL, height=DEFAULT_HEIGHT, width=DEFAULT_WIDTH, steps=1, guidance=0, number=1, seed=None):
|
| 75 |
|
| 76 |
-
repo = repo_customs[model or "Default"]
|
| 77 |
filter_input = filter_input or ""
|
| 78 |
negative_input = negative_input or DEFAULT_NEGATIVE_INPUT
|
| 79 |
steps_set = steps
|
|
@@ -111,8 +110,6 @@ def generate(input=DEFAULT_INPUT, filter_input="", negative_input=DEFAULT_NEGATI
|
|
| 111 |
guidance = guidance_set
|
| 112 |
|
| 113 |
print(steps, guidance)
|
| 114 |
-
|
| 115 |
-
repo.to(DEVICE)
|
| 116 |
|
| 117 |
parameters = {
|
| 118 |
"prompt": input,
|
|
|
|
| 10 |
import os
|
| 11 |
|
| 12 |
from diffusers import DiffusionPipeline
|
|
|
|
| 13 |
from transformers import pipeline
|
| 14 |
from peft import PeftModel
|
| 15 |
from PIL import Image
|
|
|
|
| 44 |
|
| 45 |
repo_default = DiffusionPipeline.from_pretrained("fluently/Fluently-XL-Final", device=DEVICE, torch_dtype=torch.float16, use_safetensors=True, add_watermarker=False)
|
| 46 |
|
| 47 |
+
# repo_large = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16, add_watermarker=False, revision="refs/pr/1")
|
| 48 |
# repo_large.load_lora_weights("ehristoforu/dalle-3-xl-v2", adapter_name="base")
|
| 49 |
# repo_large.set_adapters(["base"], adapter_weights=[0.7])
|
| 50 |
|
| 51 |
repo_customs = {
|
| 52 |
"Default": repo_default,
|
| 53 |
+
"Realistic": DiffusionPipeline.from_pretrained("ehristoforu/Visionix-alpha", torch_dtype=torch.float16, use_safetensors=True, add_watermarker=False),
|
| 54 |
+
"Anime": DiffusionPipeline.from_pretrained("cagliostrolab/animagine-xl-3.1", torch_dtype=torch.float16, use_safetensors=True, add_watermarker=False),
|
| 55 |
"Pixel": repo_default,
|
| 56 |
# "Large": repo_neo,
|
| 57 |
}
|
|
|
|
| 72 |
@spaces.GPU(duration=60)
|
| 73 |
def generate(input=DEFAULT_INPUT, filter_input="", negative_input=DEFAULT_NEGATIVE_INPUT, model=DEFAULT_MODEL, height=DEFAULT_HEIGHT, width=DEFAULT_WIDTH, steps=1, guidance=0, number=1, seed=None):
|
| 74 |
|
| 75 |
+
repo = repo_customs[model or "Default"].to(DEVICE)
|
| 76 |
filter_input = filter_input or ""
|
| 77 |
negative_input = negative_input or DEFAULT_NEGATIVE_INPUT
|
| 78 |
steps_set = steps
|
|
|
|
| 110 |
guidance = guidance_set
|
| 111 |
|
| 112 |
print(steps, guidance)
|
|
|
|
|
|
|
| 113 |
|
| 114 |
parameters = {
|
| 115 |
"prompt": input,
|