Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,39 +1,28 @@
|
|
| 1 |
-
import
|
| 2 |
-
from
|
| 3 |
-
from diffusers.utils import export_to_video
|
| 4 |
-
import streamlit as st
|
| 5 |
-
from diffusers import UNet2DConditionModel, TextEncoder, VQModel
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
vae_model_name = "vae/diffusion_pytorch_model.bin"
|
| 11 |
|
| 12 |
-
#
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
prompt = st.text_input("Enter your text prompt:", "Spiderman is surfing")
|
| 17 |
|
| 18 |
-
#
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 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)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|