Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -7,21 +7,12 @@ import spaces
|
|
7 |
|
8 |
device=torch.device('cuda')
|
9 |
|
10 |
-
# Load the model and LoRA weights
|
11 |
-
pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16)
|
12 |
-
print(prompt)
|
13 |
-
|
14 |
-
if style=='shou_xin':
|
15 |
-
prompt= "shou_xin, " + prompt
|
16 |
-
pipe.load_lora_weights("Datou1111/shou_xin", weight_name="shou_xin.safetensors")
|
17 |
-
else:
|
18 |
-
prompt= "sketched style, " + prompt
|
19 |
-
pipe.load_lora_weights("Shakker-Labs/FLUX.1-dev-LoRA-Children-Simple-Sketch", weight_name="FLUX-dev-lora-children-simple-sketch.safetensors")
|
20 |
-
|
21 |
|
22 |
|
23 |
-
|
24 |
-
|
|
|
|
|
25 |
|
26 |
# Load the NSFW classifier
|
27 |
image_classifier = pipeline("image-classification", model="Falconsai/nsfw_image_detection",device=device)
|
@@ -40,7 +31,18 @@ def generate_sketch(prompt,style, num_inference_steps, guidance_scale):
|
|
40 |
#for result in text_classification:
|
41 |
# if result['label'] == 'nsfw' and result['score'] > NSFW_THRESHOLD:
|
42 |
# return gr.update(visible=False),gr.Text(value="Inappropriate prompt detected. Please try another prompt.")
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
image = pipe("sketched style, " + prompt,
|
46 |
num_inference_steps=num_inference_steps,
|
|
|
7 |
|
8 |
device=torch.device('cuda')
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
|
12 |
+
|
13 |
+
|
14 |
+
|
15 |
+
|
16 |
|
17 |
# Load the NSFW classifier
|
18 |
image_classifier = pipeline("image-classification", model="Falconsai/nsfw_image_detection",device=device)
|
|
|
31 |
#for result in text_classification:
|
32 |
# if result['label'] == 'nsfw' and result['score'] > NSFW_THRESHOLD:
|
33 |
# return gr.update(visible=False),gr.Text(value="Inappropriate prompt detected. Please try another prompt.")
|
34 |
+
print(prompt)
|
35 |
+
|
36 |
+
pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16)
|
37 |
+
if style=='shou_xin':
|
38 |
+
prompt= "shou_xin, " + prompt
|
39 |
+
pipe.load_lora_weights("Datou1111/shou_xin", weight_name="shou_xin.safetensors")
|
40 |
+
else:
|
41 |
+
prompt= "sketched style, " + prompt
|
42 |
+
pipe.load_lora_weights("Shakker-Labs/FLUX.1-dev-LoRA-Children-Simple-Sketch", weight_name="FLUX-dev-lora-children-simple-sketch.safetensors")
|
43 |
+
|
44 |
+
pipe.fuse_lora(lora_scale=1.5)
|
45 |
+
pipe.to("cuda")
|
46 |
|
47 |
image = pipe("sketched style, " + prompt,
|
48 |
num_inference_steps=num_inference_steps,
|