not-lain commited on
Commit
a34fcb2
·
1 Parent(s): bbc1d54

minor changes to running the model

Browse files
Files changed (1) hide show
  1. app.py +11 -14
app.py CHANGED
@@ -1,7 +1,7 @@
1
  from diffusers import StableDiffusionPipeline
2
  import torch
3
- work_around_for_hugging_face_gradio_sdk_bug = "/blob/main/rem_3k.ckpt"
4
- model_url = "https://huggingface.co/waifu-research-department/Rem" + work_around_for_hugging_face_gradio_sdk_bug
5
  pipeline = StableDiffusionPipeline.from_single_file(
6
  model_url,
7
  torch_dtype=torch.float16,
@@ -48,22 +48,19 @@ image # your image is saved in this PIL variable
48
  ```
49
  """
50
 
51
-
52
- log = "GPU available"
53
- try :
54
  pipeline.to("cuda")
55
- except :
56
  log = "no GPU available"
57
 
58
 
59
  def text2img(positive_prompt,negative_prompt):
60
- global log
61
- if log == "no GPU available":
62
- image = None
63
- return log,image
64
- else :
65
- image = pipeline(positive_prompt,negative_prompt=negative_prompt).images[0]
66
- log = {"postive_prompt":positive_prompt,"negative_prompt":negative_prompt}
67
- return log,image
68
 
69
  gr.Interface(text2img,["text","text"],["text","image"],examples=[["rem","3D"]],description=description).launch()
 
1
  from diffusers import StableDiffusionPipeline
2
  import torch
3
+ file_name = "/blob/main/rem_3k.ckpt"
4
+ model_url = "https://huggingface.co/waifu-research-department/Rem" + file_name
5
  pipeline = StableDiffusionPipeline.from_single_file(
6
  model_url,
7
  torch_dtype=torch.float16,
 
48
  ```
49
  """
50
 
51
+ try :
 
 
52
  pipeline.to("cuda")
53
+ except:
54
  log = "no GPU available"
55
 
56
 
57
  def text2img(positive_prompt,negative_prompt):
58
+ try :
59
+ image = pipeline(positive_prompt,negative_prompt=negative_prompt).images[0]
60
+ log = {"postive_prompt":positive_prompt,"negative_prompt":negative_prompt}
61
+ except Exception as e:
62
+ log = f"ERROR: {e}"
63
+ image = None
64
+ return log,image
 
65
 
66
  gr.Interface(text2img,["text","text"],["text","image"],examples=[["rem","3D"]],description=description).launch()