|
import torch |
|
from transformers import AutoTokenizer, AutoModel |
|
import gradio as gr |
|
|
|
|
|
model_name = "openai/jukebox-1b-lyrics" |
|
|
|
|
|
tokenizer = AutoTokenizer.from_pretrained(model_name) |
|
model = AutoModel.from_pretrained(model_name, ignore_mismatched_sizes=True) |
|
|
|
|
|
def generate_music(prompt, genre): |
|
|
|
inputs = tokenizer(prompt, genres=genre, return_tensors="pt") |
|
outputs = model(**inputs) |
|
return "Generated instrumental music or lyrics" |
|
|
|
|
|
interface = gr.Interface( |
|
fn=generate_music, |
|
inputs=[ |
|
gr.inputs.Textbox(label="Prompt"), |
|
gr.inputs.Textbox(label="Genre") |
|
], |
|
outputs="text", |
|
title="Jukebox Music Generator", |
|
description="Enter a prompt and genre to generate instrumental music using the Jukebox 1B Lyrics model." |
|
) |
|
|
|
|
|
interface.launch(share=True) |
|
|