Binancenode commited on
Commit
dc6cc3c
·
verified ·
1 Parent(s): d30ba87

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -8
app.py CHANGED
@@ -1,11 +1,31 @@
 
 
1
  import gradio as gr
2
 
3
- with gr.Blocks(fill_height=True) as demo:
4
- with gr.Sidebar():
5
- gr.Markdown("# Inference Provider")
6
- gr.Markdown("This Space showcases the WolfAether21/NSFW-STABLE-DIFFUSION-LORA model, served by the hf-inference API. Sign in with your Hugging Face account to use this API.")
7
- share=True
8
- button = gr.LoginButton("Sign in")
9
- gr.load("models/WolfAether21/NSFW-STABLE-DIFFUSION-LORA", accept_token=button, provider="hf-inference")
10
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  demo.launch()
 
1
+ import torch
2
+ from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler
3
  import gradio as gr
4
 
5
+ # Basismodell laden
6
+ base_model = "runwayml/stable-diffusion-v1-5"
7
+ pipe = StableDiffusionPipeline.from_pretrained(base_model, torch_dtype=torch.float16).to("cuda")
8
+
9
+ # Optional: NSFW-Filter deaktivieren
10
+ pipe.safety_checker = lambda images, **kwargs: (images, False)
11
+
12
+ # LoRA laden (Beispiel: LoRA-Dateien lokal gespeichert)
13
+ pipe.load_lora_weights("path/to/lora_weights")
14
+
15
+ # LoRA aktivieren (nur nötig bei manchen Implementierungen)
16
+ pipe.fuse_lora()
17
+
18
+ def generate(prompt):
19
+ image = pipe(prompt).images[0]
20
+ return image
21
+
22
+ with gr.Blocks() as demo:
23
+ with gr.Row():
24
+ gr.Markdown("## NSFW Uncensored + LoRA Stable Diffusion")
25
+ prompt = gr.Textbox(label="Prompt", placeholder="Eingabe z.B. 'a nude portrait in oil painting style'")
26
+ output = gr.Image()
27
+ btn = gr.Button("Generate")
28
+
29
+ btn.click(fn=generate, inputs=prompt, outputs=output)
30
+
31
  demo.launch()