SpiderReddy commited on
Commit
717b40c
·
verified ·
1 Parent(s): 5a21b0d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -3,6 +3,7 @@ import cv2
3
  import numpy as np
4
  from diffusers import AutoPipelineForImage2Image
5
  from diffusers.utils import load_image
 
6
 
7
  # Load the anime-style diffusion model
8
  pipe = AutoPipelineForImage2Image.from_pretrained(
@@ -13,8 +14,9 @@ pipe = AutoPipelineForImage2Image.from_pretrained(
13
 
14
  # Function to process a single frame
15
  def process_frame(frame, prompt):
16
- frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
17
- image = load_image(frame_rgb)
 
18
  result = pipe(prompt=prompt, image=image, strength=0.75).images[0]
19
  return np.array(result)
20
 
@@ -50,12 +52,12 @@ iface = gr.Interface(
50
  fn=video_to_anime,
51
  inputs=[
52
  gr.Video(label="Input Video"),
53
- gr.Textbox(label="Style Prompt", value="Arcane style") # Changed 'default' to 'value'
54
  ],
55
  outputs=gr.Video(label="Output Video"),
56
  title="Video to Anime Converter",
57
  description="Upload a video and convert it to anime style!"
58
  )
59
 
60
- # Launch the interface
61
- iface.launch()
 
3
  import numpy as np
4
  from diffusers import AutoPipelineForImage2Image
5
  from diffusers.utils import load_image
6
+ from PIL import Image # Add this import
7
 
8
  # Load the anime-style diffusion model
9
  pipe = AutoPipelineForImage2Image.from_pretrained(
 
14
 
15
  # Function to process a single frame
16
  def process_frame(frame, prompt):
17
+ frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) # Convert BGR to RGB
18
+ pil_image = Image.fromarray(frame_rgb) # Convert NumPy array to PIL image
19
+ image = load_image(pil_image) # Pass PIL image to load_image
20
  result = pipe(prompt=prompt, image=image, strength=0.75).images[0]
21
  return np.array(result)
22
 
 
52
  fn=video_to_anime,
53
  inputs=[
54
  gr.Video(label="Input Video"),
55
+ gr.Textbox(label="Style Prompt", value="Arcane style")
56
  ],
57
  outputs=gr.Video(label="Output Video"),
58
  title="Video to Anime Converter",
59
  description="Upload a video and convert it to anime style!"
60
  )
61
 
62
+ # Launch the interface with a public link
63
+ iface.launch(share=True) # Added share=True as per the suggestion