Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,6 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
| 2 |
# from datasets import load_dataset
|
| 3 |
from PIL import Image
|
| 4 |
import torch
|
|
@@ -18,7 +20,7 @@ base_dir = "./huggingface/hub"
|
|
| 18 |
if not os.path.isdir(base_dir):
|
| 19 |
os.makedirs(base_dir)
|
| 20 |
|
| 21 |
-
cmd_list = ["cd", base_dir, "&&", "git lfs install", "&&", "git clone", "https://gitee.com/modelee/stable-diffusion-2.git"]
|
| 22 |
cmd_str = " ".join(cmd_list)
|
| 23 |
print("cmd_str:", cmd_str)
|
| 24 |
ret, out = subprocess.getstatusoutput(cmd_str)
|
|
@@ -42,8 +44,8 @@ def infer(prompt, negative, scale):
|
|
| 42 |
|
| 43 |
model_id = base_dir
|
| 44 |
# Use the Euler scheduler here instead
|
| 45 |
-
scheduler =
|
| 46 |
-
pipe =
|
| 47 |
# pipe = pipe.to("cuda")
|
| 48 |
images = pipe(prompt).images
|
| 49 |
return images
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 4 |
# from datasets import load_dataset
|
| 5 |
from PIL import Image
|
| 6 |
import torch
|
|
|
|
| 20 |
if not os.path.isdir(base_dir):
|
| 21 |
os.makedirs(base_dir)
|
| 22 |
|
| 23 |
+
cmd_list = ["cd", base_dir, "&&", "git lfs install", "&&", "git clone", "https://gitee.com/modelee/stable-diffusion-2.git", "models"]
|
| 24 |
cmd_str = " ".join(cmd_list)
|
| 25 |
print("cmd_str:", cmd_str)
|
| 26 |
ret, out = subprocess.getstatusoutput(cmd_str)
|
|
|
|
| 44 |
|
| 45 |
model_id = base_dir
|
| 46 |
# Use the Euler scheduler here instead
|
| 47 |
+
scheduler = AutoTokenizer.from_pretrained(pretrained_model_name_or_path=model_id)
|
| 48 |
+
pipe = AutoModelForCausalLM.from_pretrained(pretrained_model_name_or_path=model_id)
|
| 49 |
# pipe = pipe.to("cuda")
|
| 50 |
images = pipe(prompt).images
|
| 51 |
return images
|