Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -94,7 +94,7 @@ from transformers import pipeline
|
|
| 94 |
zephyr_model = "HuggingFaceH4/zephyr-7b-beta"
|
| 95 |
mixtral_model = "mistralai/Mixtral-8x7B-Instruct-v0.1"
|
| 96 |
|
| 97 |
-
pipe = pipeline("text-generation", model=
|
| 98 |
|
| 99 |
agent_maker_sys = f"""
|
| 100 |
You are an AI whose job is to help users create their own music which its genre will reflect the character or scene from an image described by users.
|
|
@@ -118,7 +118,7 @@ def infer(image_in):
|
|
| 118 |
prompt = f"{instruction.strip()}\n{user_prompt}</s>"
|
| 119 |
#print(f"PROMPT: {prompt}")
|
| 120 |
|
| 121 |
-
gr.Info("Building a
|
| 122 |
outputs = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
|
| 123 |
|
| 124 |
|
|
@@ -127,11 +127,12 @@ def infer(image_in):
|
|
| 127 |
|
| 128 |
print(f"SUGGESTED Musical prompt: {cleaned_text}")
|
| 129 |
|
|
|
|
| 130 |
music_o = get_magnet(cleaned_text)
|
| 131 |
|
| 132 |
return cleaned_text.lstrip("\n"), music_o
|
| 133 |
|
| 134 |
-
|
| 135 |
description = "Get music from a picture"
|
| 136 |
|
| 137 |
css = """
|
|
@@ -145,7 +146,7 @@ css = """
|
|
| 145 |
with gr.Blocks(css=css) as demo:
|
| 146 |
with gr.Column(elem_id="col-container"):
|
| 147 |
gr.HTML(f"""
|
| 148 |
-
<h2 style="text-align: center;">{
|
| 149 |
<p style="text-align: center;">{description}</p>
|
| 150 |
""")
|
| 151 |
|
|
@@ -156,7 +157,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 156 |
type = "filepath",
|
| 157 |
elem_id = "image-in"
|
| 158 |
)
|
| 159 |
-
submit_btn = gr.Button("Make
|
| 160 |
with gr.Column():
|
| 161 |
caption = gr.Textbox(
|
| 162 |
label = "Musical prompt"
|
|
|
|
| 94 |
zephyr_model = "HuggingFaceH4/zephyr-7b-beta"
|
| 95 |
mixtral_model = "mistralai/Mixtral-8x7B-Instruct-v0.1"
|
| 96 |
|
| 97 |
+
pipe = pipeline("text-generation", model=zephyr_model, torch_dtype=torch.bfloat16, device_map="auto")
|
| 98 |
|
| 99 |
agent_maker_sys = f"""
|
| 100 |
You are an AI whose job is to help users create their own music which its genre will reflect the character or scene from an image described by users.
|
|
|
|
| 118 |
prompt = f"{instruction.strip()}\n{user_prompt}</s>"
|
| 119 |
#print(f"PROMPT: {prompt}")
|
| 120 |
|
| 121 |
+
gr.Info("Building a musical prompt according to the image caption ...")
|
| 122 |
outputs = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
|
| 123 |
|
| 124 |
|
|
|
|
| 127 |
|
| 128 |
print(f"SUGGESTED Musical prompt: {cleaned_text}")
|
| 129 |
|
| 130 |
+
gr.Info("Now calling MAGNet for music ...")
|
| 131 |
music_o = get_magnet(cleaned_text)
|
| 132 |
|
| 133 |
return cleaned_text.lstrip("\n"), music_o
|
| 134 |
|
| 135 |
+
demo_title = "Image to Music V2"
|
| 136 |
description = "Get music from a picture"
|
| 137 |
|
| 138 |
css = """
|
|
|
|
| 146 |
with gr.Blocks(css=css) as demo:
|
| 147 |
with gr.Column(elem_id="col-container"):
|
| 148 |
gr.HTML(f"""
|
| 149 |
+
<h2 style="text-align: center;">{demo_title}</h2>
|
| 150 |
<p style="text-align: center;">{description}</p>
|
| 151 |
""")
|
| 152 |
|
|
|
|
| 157 |
type = "filepath",
|
| 158 |
elem_id = "image-in"
|
| 159 |
)
|
| 160 |
+
submit_btn = gr.Button("Make music from my pic !")
|
| 161 |
with gr.Column():
|
| 162 |
caption = gr.Textbox(
|
| 163 |
label = "Musical prompt"
|