Prgckwb commited on
Commit
dc8517c
1 Parent(s): 0199443

:tada: add negative embedding

Browse files
Files changed (1) hide show
  1. app.py +15 -17
app.py CHANGED
@@ -94,29 +94,27 @@ def inference(
94
 
95
  progress(0.1, 'Loading pipeline...')
96
  if model_id != current_model_id:
97
- try:
98
- # For NOT Diffusers' Models
99
- if model_id not in DIFFUSERS_MODEL_IDS:
100
- model_id = EXTERNAL_MODEL_MAPPING[model_id]
101
 
102
- pipe = DiffusionPipeline.from_pretrained(
103
- model_id,
104
- torch_dtype=dtype,
105
- )
106
- pipe.enable_sequential_cpu_offload()
107
 
108
- current_model_id = model_id
109
- except Exception as e:
110
- raise gr.Error(str(e))
111
 
112
  if not safety_checker:
113
  pipe.safety_checker = None
114
 
115
- progress(0.3, 'Loading Textual Inversion...')
116
- # Load Textual Inversion
117
- pipe.load_textual_inversion(
118
- "checkpoints/embeddings/BadNegAnatomyV1 neg.pt", token='BadNegAnatomyV1-neg'
119
- )
 
120
 
121
  # Generation
122
  progress(0.4, 'Generating images...')
 
94
 
95
  progress(0.1, 'Loading pipeline...')
96
  if model_id != current_model_id:
97
+ # For NOT Diffusers' Models
98
+ if model_id not in DIFFUSERS_MODEL_IDS:
99
+ model_id = EXTERNAL_MODEL_MAPPING[model_id]
 
100
 
101
+ pipe = DiffusionPipeline.from_pretrained(
102
+ model_id,
103
+ torch_dtype=dtype,
104
+ )
105
+ pipe.enable_sequential_cpu_offload()
106
 
107
+ current_model_id = model_id
 
 
108
 
109
  if not safety_checker:
110
  pipe.safety_checker = None
111
 
112
+ if model_id not in DIFFUSERS_MODEL_IDS:
113
+ progress(0.3, 'Loading Textual Inversion...')
114
+ # Load Textual Inversion
115
+ pipe.load_textual_inversion(
116
+ "checkpoints/embeddings/BadNegAnatomyV1 neg.pt", token='BadNegAnatomyV1-neg'
117
+ )
118
 
119
  # Generation
120
  progress(0.4, 'Generating images...')