Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@
|
|
4 |
# in the Software without restriction, including without limitation the rights
|
5 |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
6 |
# copies of the Software, and to permit persons to whom the Software is
|
|
|
7 |
import spaces
|
8 |
import os
|
9 |
import random
|
@@ -12,15 +13,14 @@ import gradio as gr
|
|
12 |
import numpy as np
|
13 |
from PIL import Image
|
14 |
import torch
|
15 |
-
#import diffusers
|
16 |
-
from diffusers import AutoencoderKL, StableDiffusionXLPipeline
|
17 |
-
from diffusers import EulerAncestralDiscreteScheduler
|
18 |
from typing import Tuple
|
19 |
import paramiko
|
20 |
import datetime
|
21 |
-
#
|
|
|
22 |
from diffusers.models.attention_processor import AttnProcessor2_0
|
23 |
from transformers import CLIPTextModelWithProjection, CLIPTextModel, CLIPTokenizer
|
|
|
24 |
torch.backends.cuda.matmul.allow_tf32 = False
|
25 |
torch.backends.cuda.matmul.allow_bf16_reduced_precision_reduction = False
|
26 |
torch.backends.cuda.matmul.allow_fp16_reduced_precision_reduction = False
|
@@ -37,7 +37,7 @@ FTP_PASS = os.getenv("FTP_PASS")
|
|
37 |
FTP_DIR = "1ink.us/stable_diff/" # Remote directory on FTP server
|
38 |
|
39 |
DESCRIPTIONXX = """
|
40 |
-
## ⚡⚡⚡⚡ REALVISXL V5.0 BF16 (Tester
|
41 |
"""
|
42 |
|
43 |
examples = [
|
@@ -89,7 +89,7 @@ tokenizer_1=CLIPTokenizer.from_pretrained('ford442/RealVisXL_V5.0_BF16', low_cpu
|
|
89 |
tokenizer_2=CLIPTokenizer.from_pretrained('ford442/RealVisXL_V5.0_BF16', low_cpu_mem_usage=False, subfolder='tokenizer_2',token=True)
|
90 |
scheduler=EulerAncestralDiscreteScheduler.from_pretrained('ford442/RealVisXL_V5.0_BF16', low_cpu_mem_usage=False, subfolder='scheduler',token=True)
|
91 |
vaeXL = AutoencoderKL.from_pretrained("stabilityai/sdxl-vae", low_cpu_mem_usage=False, safety_checker=None, use_safetensors=False, torch_dtype=torch.float32, token=True) #.to(device).to(torch.bfloat16) #.to(device=device, dtype=torch.bfloat16)
|
92 |
-
|
93 |
def load_and_prepare_model():
|
94 |
#vaeRV = AutoencoderKL.from_pretrained("SG161222/RealVisXL_V5.0", subfolder='vae', safety_checker=None, use_safetensors=True, token=True)
|
95 |
#vaeXL = AutoencoderKL.from_pretrained("stabilityai/sdxl-vae", safety_checker=None, use_safetensors=False, low_cpu_mem_usage=False, torch_dtype=torch.float32, token=True) #.to(device).to(torch.bfloat16) #.to(device=device, dtype=torch.bfloat16)
|
@@ -163,16 +163,14 @@ def save_image(img):
|
|
163 |
return unique_name
|
164 |
|
165 |
def uploadNote(prompt,num_inference_steps,guidance_scale,timestamp):
|
166 |
-
filename= f'
|
167 |
with open(filename, "w") as f:
|
168 |
-
f.write(f"Realvis 5.0 (Tester
|
169 |
f.write(f"Date/time: {timestamp} \n")
|
170 |
f.write(f"Prompt: {prompt} \n")
|
171 |
f.write(f"Steps: {num_inference_steps} \n")
|
172 |
f.write(f"Guidance Scale: {guidance_scale} \n")
|
173 |
f.write(f"SPACE SETUP: \n")
|
174 |
-
f.write(f"Use Model Dtype: no \n")
|
175 |
-
f.write(f"Model Scheduler: Euler_a all_custom before cuda \n")
|
176 |
f.write(f"To cuda and bfloat \n")
|
177 |
upload_to_ftp(filename)
|
178 |
|
@@ -470,8 +468,6 @@ with gr.Blocks(theme=gr.themes.Origin(),css=css) as demo:
|
|
470 |
gr.Markdown("### REALVISXL V5.0")
|
471 |
predefined_gallery = gr.Gallery(label="REALVISXL V5.0", columns=3, show_label=False, value=load_predefined_images1())
|
472 |
|
473 |
-
#gr.Markdown("### LIGHTNING V5.0")
|
474 |
-
#predefined_gallery = gr.Gallery(label="LIGHTNING V5.0", columns=3, show_label=False, value=load_predefined_images())
|
475 |
|
476 |
gr.Markdown(
|
477 |
"""
|
|
|
4 |
# in the Software without restriction, including without limitation the rights
|
5 |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
6 |
# copies of the Software, and to permit persons to whom the Software is
|
7 |
+
|
8 |
import spaces
|
9 |
import os
|
10 |
import random
|
|
|
13 |
import numpy as np
|
14 |
from PIL import Image
|
15 |
import torch
|
|
|
|
|
|
|
16 |
from typing import Tuple
|
17 |
import paramiko
|
18 |
import datetime
|
19 |
+
#import diffusers
|
20 |
+
from diffusers import StableDiffusionXLPipeline, UNet2DConditionModel, AutoencoderKL, EulerAncestralDiscreteScheduler
|
21 |
from diffusers.models.attention_processor import AttnProcessor2_0
|
22 |
from transformers import CLIPTextModelWithProjection, CLIPTextModel, CLIPTokenizer
|
23 |
+
|
24 |
torch.backends.cuda.matmul.allow_tf32 = False
|
25 |
torch.backends.cuda.matmul.allow_bf16_reduced_precision_reduction = False
|
26 |
torch.backends.cuda.matmul.allow_fp16_reduced_precision_reduction = False
|
|
|
37 |
FTP_DIR = "1ink.us/stable_diff/" # Remote directory on FTP server
|
38 |
|
39 |
DESCRIPTIONXX = """
|
40 |
+
## ⚡⚡⚡⚡ REALVISXL V5.0 BF16 (Tester G) ⚡⚡⚡⚡
|
41 |
"""
|
42 |
|
43 |
examples = [
|
|
|
89 |
tokenizer_2=CLIPTokenizer.from_pretrained('ford442/RealVisXL_V5.0_BF16', low_cpu_mem_usage=False, subfolder='tokenizer_2',token=True)
|
90 |
scheduler=EulerAncestralDiscreteScheduler.from_pretrained('ford442/RealVisXL_V5.0_BF16', low_cpu_mem_usage=False, subfolder='scheduler',token=True)
|
91 |
vaeXL = AutoencoderKL.from_pretrained("stabilityai/sdxl-vae", low_cpu_mem_usage=False, safety_checker=None, use_safetensors=False, torch_dtype=torch.float32, token=True) #.to(device).to(torch.bfloat16) #.to(device=device, dtype=torch.bfloat16)
|
92 |
+
UNet2DConditionModel
|
93 |
def load_and_prepare_model():
|
94 |
#vaeRV = AutoencoderKL.from_pretrained("SG161222/RealVisXL_V5.0", subfolder='vae', safety_checker=None, use_safetensors=True, token=True)
|
95 |
#vaeXL = AutoencoderKL.from_pretrained("stabilityai/sdxl-vae", safety_checker=None, use_safetensors=False, low_cpu_mem_usage=False, torch_dtype=torch.float32, token=True) #.to(device).to(torch.bfloat16) #.to(device=device, dtype=torch.bfloat16)
|
|
|
163 |
return unique_name
|
164 |
|
165 |
def uploadNote(prompt,num_inference_steps,guidance_scale,timestamp):
|
166 |
+
filename= f'tst_G_{timestamp}.txt'
|
167 |
with open(filename, "w") as f:
|
168 |
+
f.write(f"Realvis 5.0 (Tester G) \n")
|
169 |
f.write(f"Date/time: {timestamp} \n")
|
170 |
f.write(f"Prompt: {prompt} \n")
|
171 |
f.write(f"Steps: {num_inference_steps} \n")
|
172 |
f.write(f"Guidance Scale: {guidance_scale} \n")
|
173 |
f.write(f"SPACE SETUP: \n")
|
|
|
|
|
174 |
f.write(f"To cuda and bfloat \n")
|
175 |
upload_to_ftp(filename)
|
176 |
|
|
|
468 |
gr.Markdown("### REALVISXL V5.0")
|
469 |
predefined_gallery = gr.Gallery(label="REALVISXL V5.0", columns=3, show_label=False, value=load_predefined_images1())
|
470 |
|
|
|
|
|
471 |
|
472 |
gr.Markdown(
|
473 |
"""
|