Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline, Conversation
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from diffusers import DiffusionPipeline
|
| 4 |
+
import gradio as gr
|
| 5 |
+
from transformers import pipeline
|
| 6 |
+
import scipy
|
| 7 |
+
import gradio as gr
|
| 8 |
+
chatbot = pipeline(model="facebook/blenderbot-400M-distill")
|
| 9 |
+
message_list = []
|
| 10 |
+
response_list = []
|
| 11 |
+
def vanilla_chatbot(message, history):
|
| 12 |
+
conversation = Conversation(text=message, past_user_inputs=message_list, generated_responses=response_list)
|
| 13 |
+
bot = chatbot(conversation.messages[0]['content']) # working code
|
| 14 |
+
return bot[-1]['generated_text']
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
model_id = "CompVis/ldm-text2im-large-256"
|
| 18 |
+
ldm = DiffusionPipeline.from_pretrained(model_id)
|
| 19 |
+
def generate_image(Prompt):
|
| 20 |
+
images = ldm([Prompt], num_inference_steps=50, eta=.3, guidance_scale=6)
|
| 21 |
+
return images.images[0]
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
synthesiser = pipeline("text-to-audio", "facebook/musicgen-small")
|
| 25 |
+
def generate_music(Prompt):
|
| 26 |
+
music = synthesiser(Prompt, forward_params={"do_sample": True, "max_new_tokens":100})
|
| 27 |
+
rate = music["sampling_rate"]
|
| 28 |
+
mus = music["audio"][0].reshape(-1)
|
| 29 |
+
return rate,mus
|