reshav1 commited on
Commit
31c316e
·
verified ·
1 Parent(s): fce9855

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -35
app.py CHANGED
@@ -1,39 +1,28 @@
1
- import torch
2
- from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler
3
- from diffusers.utils import export_to_video
4
- import streamlit as st
5
- from diffusers import UNet2DConditionModel, TextEncoder, VQModel
6
 
7
- # Use the default model names here
8
- unet_model_name = "unet/diffusion_pytorch_model.bin"
9
- text_encoder_name = "text_encoder/pytorch_model.bin"
10
- vae_model_name = "vae/diffusion_pytorch_model.bin"
11
 
12
- # Create the pipeline or model objects using the default names
13
- pipeline = UNet2DConditionModel.from_pretrained(unet_model_name)
14
- # Title and User Input
15
- st.title("Text-to-Video with Streamlit")
16
- prompt = st.text_input("Enter your text prompt:", "Spiderman is surfing")
17
 
18
- # Button to trigger generation
19
- if st.button("Generate Video"):
20
- st.video(video_path)
 
 
 
 
 
21
 
22
- # Ensure you have 'accelerate' version 0.17.0 or higher (see previous explanation)
23
- import accelerate
24
- if accelerate.__version__ < "0.17.0":
25
- st.warning("Please upgrade 'accelerate' to version 0.17.0 or higher for CPU offloading.")
26
- else:
27
- with st.spinner("Generating video..."):
28
- pipe = DiffusionPipeline.from_pretrained("cerspense/zeroscope_v2_576w",
29
- torch_dtype=torch.float16,
30
- variant="fp16",
31
- device="cpu") # Force CPU usage
32
- pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
33
- pipe.enable_model_cpu_offload() # Assuming 'accelerate' is updated
34
-
35
- video_frames = pipe(prompt, num_inference_steps=25).frames
36
- video_path = export_to_video(video_frames)
37
-
38
- # Display the video in the Streamlit app
39
- st.video(video_path)
 
1
+ import transformers
2
+ from transformers import DistilBertTokenizer, DistilBertForSequenceClassification
 
 
 
3
 
4
+ # Load tokenizer and model
5
+ tokenizer = DistilBertTokenizer.from_pretrained('distilbert-base-uncased')
6
+ model = DistilBertForSequenceClassification.from_pretrained('distilbert-base-uncased')
 
7
 
8
+ # Define a function to preprocess user input
9
+ def preprocess_input(text):
10
+ encoded_input = tokenizer(text, return_tensors='pt')
11
+ return encoded_input
 
12
 
13
+ # Define a function to generate response based on user input
14
+ def generate_response(user_input):
15
+ encoded_input = preprocess_input(user_input)
16
+ outputs = model(**encoded_input)
17
+ # Extract relevant information from model outputs (e.g., predicted class)
18
+ # Based on the extracted information, formulate a response using predefined responses or logic
19
+ response = "I'm still under development, but I understand you said: {}".format(user_input)
20
+ return response
21
 
22
+ # Start the chat loop
23
+ while True:
24
+ user_input = input("You: ")
25
+ if user_input == "quit":
26
+ break
27
+ bot_response = generate_response(user_input)
28
+ print("Bot:", bot_response)