Spaces:
Sleeping
Sleeping
Raumkommander
commited on
Commit
·
0cef02f
1
Parent(s):
9df1739
inital deployment1
Browse files
app.py
CHANGED
@@ -2,6 +2,38 @@ import torch
|
|
2 |
import gradio as gr
|
3 |
from diffusers import StableDiffusionPipeline, LCMScheduler
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
# Load the pre-trained Real-Time LCM model
|
6 |
model_id = "SimianLuo/LCM_Dreamshaper_v7"
|
7 |
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
@@ -13,14 +45,13 @@ def generate_image(prompt: str):
|
|
13 |
image = pipe(prompt, num_inference_steps=4).images[0]
|
14 |
return image
|
15 |
|
16 |
-
# Create Gradio interface
|
17 |
-
iface = gr.Interface(
|
18 |
-
fn=generate_image,
|
19 |
-
inputs=gr.Textbox(label="Enter a prompt"),
|
20 |
-
outputs=gr.Image(label="Generated Image"),
|
21 |
-
title="Real-Time LCM Image Generator",
|
22 |
-
description="Enter a prompt and get an AI-generated image in real time using Latent Consistency Models."
|
23 |
-
)
|
24 |
-
|
25 |
if __name__ == "__main__":
|
26 |
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
import gradio as gr
|
3 |
from diffusers import StableDiffusionPipeline, LCMScheduler
|
4 |
|
5 |
+
|
6 |
+
import gradio as gr
|
7 |
+
import cv2
|
8 |
+
import numpy as np
|
9 |
+
|
10 |
+
# Function to process the video frame
|
11 |
+
def process_frame(frame):
|
12 |
+
# Convert frame to grayscale (example processing step)
|
13 |
+
gray_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
|
14 |
+
return gray_frame
|
15 |
+
|
16 |
+
# Function to capture video feed
|
17 |
+
def video_stream():
|
18 |
+
cap = cv2.VideoCapture(0) # Open webcam
|
19 |
+
while True:
|
20 |
+
ret, frame = cap.read()
|
21 |
+
if not ret:
|
22 |
+
break
|
23 |
+
processed_frame = process_frame(frame) # Apply processing
|
24 |
+
yield processed_frame # Return processed frame
|
25 |
+
cap.release()
|
26 |
+
|
27 |
+
# Create the Gradio interface
|
28 |
+
iface = gr.Interface(
|
29 |
+
fn=video_stream,
|
30 |
+
inputs=[],
|
31 |
+
outputs=gr.Video(label="Webcam Feed"),
|
32 |
+
live=True
|
33 |
+
)
|
34 |
+
|
35 |
+
|
36 |
+
|
37 |
# Load the pre-trained Real-Time LCM model
|
38 |
model_id = "SimianLuo/LCM_Dreamshaper_v7"
|
39 |
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
|
|
45 |
image = pipe(prompt, num_inference_steps=4).images[0]
|
46 |
return image
|
47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
if __name__ == "__main__":
|
49 |
iface.launch()
|
50 |
+
|
51 |
+
|
52 |
+
|
53 |
+
|
54 |
+
# Launch the Gradio app
|
55 |
+
if __name__ == "__main__":
|
56 |
+
iface.launch(share=True)
|
57 |
+
|