fffiloni commited on
Commit
f83630e
1 Parent(s): 682c6da

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -15
app.py CHANGED
@@ -4,18 +4,9 @@ import json
4
  import re
5
  from gradio_client import Client
6
 
7
- #fusecap_client = Client("https://noamrot-fusecap-image-captioning.hf.space/")
8
- #fuyu_client = Client("https://adept-fuyu-8b-demo.hf.space/")
9
  kosmos2_client = Client("https://ydshieh-kosmos-2.hf.space/")
10
 
11
  def get_caption(image_in):
12
- """
13
- fuyu_result = fuyu_client.predict(
14
- image_in, # str representing input in 'raw_image' Image component
15
- True, # bool in 'Enable detailed captioning' Checkbox component
16
- fn_index=2
17
- )
18
- """
19
 
20
  kosmos2_result = kosmos2_client.predict(
21
  image_in, # str (filepath or URL to image) in 'Test Image' Image component
@@ -67,13 +58,12 @@ def get_caption_from_MD(image_in):
67
  return result
68
 
69
  def get_magnet(prompt):
70
- amended_prompt = f"{prompt}"
71
- print(amended_prompt)
72
  client = Client("https://fffiloni-magnet.hf.space/")
73
  result = client.predict(
74
  "facebook/magnet-medium-10secs", # Literal['facebook/magnet-small-10secs', 'facebook/magnet-medium-10secs', 'facebook/magnet-small-30secs', 'facebook/magnet-medium-30secs', 'facebook/audio-magnet-small', 'facebook/audio-magnet-medium'] in 'Model' Radio component
75
  "", # str in 'Model Path (custom models)' Textbox component
76
- amended_prompt, # str in 'Input Text' Textbox component
77
  3, # float in 'Temperature' Number component
78
  0.9, # float in 'Top-p' Number component
79
  10, # float in 'Max CFG coefficient' Number component
@@ -112,7 +102,7 @@ instruction = f"""
112
  <|user|>
113
  """
114
 
115
- @spaces.GPU(enable_queue=True, duration=60)
116
  def get_musical_prompt(user_prompt):
117
  prompt = f"{instruction.strip()}\n{user_prompt}</s>"
118
  outputs = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
@@ -132,7 +122,7 @@ def infer(image_in):
132
  gr.Info("Now calling MAGNet for music ...")
133
  music_o = get_magnet(musical_prompt)
134
 
135
- return cleaned_text, music_o
136
 
137
  demo_title = "Image to Music V2"
138
  description = "Get music from a picture"
@@ -168,7 +158,7 @@ with gr.Blocks(css=css) as demo:
168
  result = gr.Audio(
169
  label = "Music"
170
  )
171
- with gr.Row():
172
  gr.Examples(
173
  examples = [
174
  ["examples/monalisa.png"],
 
4
  import re
5
  from gradio_client import Client
6
 
 
 
7
  kosmos2_client = Client("https://ydshieh-kosmos-2.hf.space/")
8
 
9
  def get_caption(image_in):
 
 
 
 
 
 
 
10
 
11
  kosmos2_result = kosmos2_client.predict(
12
  image_in, # str (filepath or URL to image) in 'Test Image' Image component
 
58
  return result
59
 
60
  def get_magnet(prompt):
61
+
 
62
  client = Client("https://fffiloni-magnet.hf.space/")
63
  result = client.predict(
64
  "facebook/magnet-medium-10secs", # Literal['facebook/magnet-small-10secs', 'facebook/magnet-medium-10secs', 'facebook/magnet-small-30secs', 'facebook/magnet-medium-30secs', 'facebook/audio-magnet-small', 'facebook/audio-magnet-medium'] in 'Model' Radio component
65
  "", # str in 'Model Path (custom models)' Textbox component
66
+ prompt, # str in 'Input Text' Textbox component
67
  3, # float in 'Temperature' Number component
68
  0.9, # float in 'Top-p' Number component
69
  10, # float in 'Max CFG coefficient' Number component
 
102
  <|user|>
103
  """
104
 
105
+ @spaces.GPU(enable_queue=True)
106
  def get_musical_prompt(user_prompt):
107
  prompt = f"{instruction.strip()}\n{user_prompt}</s>"
108
  outputs = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
 
122
  gr.Info("Now calling MAGNet for music ...")
123
  music_o = get_magnet(musical_prompt)
124
 
125
+ return musical_prompt, music_o
126
 
127
  demo_title = "Image to Music V2"
128
  description = "Get music from a picture"
 
158
  result = gr.Audio(
159
  label = "Music"
160
  )
161
+ with gr.Column():
162
  gr.Examples(
163
  examples = [
164
  ["examples/monalisa.png"],