Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import torch
|
2 |
from diffusers import FluxPipeline
|
|
|
3 |
import gradio as gr
|
4 |
import spaces
|
5 |
|
@@ -8,6 +9,7 @@ pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=
|
|
8 |
pipe.load_lora_weights("Shakker-Labs/FLUX.1-dev-LoRA-Children-Simple-Sketch", weight_name="FLUX-dev-lora-children-simple-sketch.safetensors")
|
9 |
pipe.fuse_lora(lora_scale=1.5)
|
10 |
pipe.to("cuda")
|
|
|
11 |
|
12 |
# Define the function to generate the sketch
|
13 |
@spaces.GPU
|
@@ -16,7 +18,9 @@ def generate_sketch(prompt, num_inference_steps, guidance_scale):
|
|
16 |
num_inference_steps=num_inference_steps,
|
17 |
guidance_scale=guidance_scale,
|
18 |
).images[0]
|
|
|
19 |
image_path = "generated_sketch.png"
|
|
|
20 |
image.save(image_path)
|
21 |
return image_path
|
22 |
|
|
|
1 |
import torch
|
2 |
from diffusers import FluxPipeline
|
3 |
+
from transformers import pipeline
|
4 |
import gradio as gr
|
5 |
import spaces
|
6 |
|
|
|
9 |
pipe.load_lora_weights("Shakker-Labs/FLUX.1-dev-LoRA-Children-Simple-Sketch", weight_name="FLUX-dev-lora-children-simple-sketch.safetensors")
|
10 |
pipe.fuse_lora(lora_scale=1.5)
|
11 |
pipe.to("cuda")
|
12 |
+
classifier = pipeline("image-classification", model="Falconsai/nsfw_image_detection")
|
13 |
|
14 |
# Define the function to generate the sketch
|
15 |
@spaces.GPU
|
|
|
18 |
num_inference_steps=num_inference_steps,
|
19 |
guidance_scale=guidance_scale,
|
20 |
).images[0]
|
21 |
+
print(classifier(image))
|
22 |
image_path = "generated_sketch.png"
|
23 |
+
|
24 |
image.save(image_path)
|
25 |
return image_path
|
26 |
|