HotdogOrNot / app.py
grbell's picture
Update app.py
6bdfd36 verified
"""
import streamlit as st
from transformers import pipeline
from PIL import Image
pipeline = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
st.title("Hot Dog? Or Not?")
file_name = st.file_uploader("Upload a hot dog candidate image")
if file_name is not None:
col1, col2 = st.columns(2)
image = Image.open(file_name)
col1.image(image, use_container_width=True)
predictions = pipeline(image)
col2.header("Probabilities")
for p in predictions:
col2.subheader(f"{ p['label'] }: { round(p['score'] * 100, 1)}%")
"""
import streamlit as st
from transformers import pipeline
from PIL import Image
import torch
from diffusers import CogVideoXImageToVideoPipeline
from diffusers.utils import export_to_video, load_image
prompt = "A vast, shimmering ocean flows gracefully under a twilight sky, its waves undulating in a mesmerizing dance of blues and greens. The surface glints with the last rays of the setting sun, casting golden highlights that ripple across the water. Seagulls soar above, their cries blending with the gentle roar of the waves. The horizon stretches infinitely, where the ocean meets the sky in a seamless blend of hues. Close-ups reveal the intricate patterns of the waves, capturing the fluidity and dynamic beauty of the sea in motion."
pipe = CogVideoXImageToVideoPipeline.from_pretrained(
"THUDM/CogVideoX-5b-I2V",
torch_dtype=torch.bfloat16
)
# pipe.to("cpu")
pipe.vae.enable_tiling()
pipe.vae.enable_slicing()
st.title("Image to Video")
file_name = st.file_uploader("Upload an image")
if file_name is not None:
col1, col2 = st.columns(2)
#image = load_image(image=file_name.name)
image = Image.open(file_name)
col1.image(image, use_container_width=True)
seed = 42
if torch.cuda.is_available():
generator = torch.Generator(device="cuda").manual_seed(seed)
else:
generator = torch.Generator().manual_seed(seed)
video = pipe(
prompt=prompt,
image=image,
num_videos_per_prompt=1,
num_inference_steps=50,
num_frames=49,
guidance_scale=6,
generator=generator,
).frames[0]
col2.video(video, use_container_width=True)
export_to_video(video, "output.mp4", fps=8)