fffiloni commited on
Commit
9129aed
โ€ข
1 Parent(s): 0cdafe9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -21,21 +21,23 @@ img_to_text = gr.Blocks.load(name="spaces/fffiloni/CLIP-Interrogator-2")
21
 
22
  from share_btn import community_icon_html, loading_icon_html, share_js
23
 
 
 
 
24
  def get_prompts(uploaded_image, track_duration, gen_intensity, gen_mode):
25
  print("calling clip interrogator")
26
  #prompt = img_to_text(uploaded_image, "ViT-L (best for Stable Diffusion 1.*)", "fast", fn_index=1)[0]
27
  prompt = img_to_text(uploaded_image, 'fast', 4, fn_index=1)[0]
28
  print(prompt)
29
  pat = get_pat_token()
30
- music_result = get_music(pat, prompt, track_duration, gen_intensity, gen_mode)
31
- #music_result = generate_track_by_prompt(pat, prompt, track_duration, gen_intensity, gen_mode)
32
  #print(pat)
33
  return music_result, gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
34
 
35
- #from utils import get_tags_for_prompts, get_mubert_tags_embeddings, get_pat
 
36
 
37
- #minilm = SentenceTransformer('all-MiniLM-L6-v2')
38
- #mubert_tags_embeddings = get_mubert_tags_embeddings(minilm)
39
 
40
  def get_pat_token():
41
  r = httpx.post('https://api-b2b.mubert.com/v2/GetServiceAccess',
@@ -107,9 +109,8 @@ def get_track_by_tags(tags, pat, duration, gen_intensity, gen_mode, maxit=20):
107
  time.sleep(1)
108
 
109
 
110
- def generate_track_by_prompt(prompt, duration, gen_intensity, gen_mode):
111
  try:
112
- pat = get_pat("[email protected]")
113
  _, tags = get_tags_for_prompts(minilm, mubert_tags_embeddings, [prompt, ])[0]
114
  result = get_track_by_tags(tags, pat, int(duration), gen_intensity, gen_mode)
115
  print(result)
 
21
 
22
  from share_btn import community_icon_html, loading_icon_html, share_js
23
 
24
+ minilm = SentenceTransformer('all-MiniLM-L6-v2')
25
+ mubert_tags_embeddings = get_mubert_tags_embeddings(minilm)
26
+
27
  def get_prompts(uploaded_image, track_duration, gen_intensity, gen_mode):
28
  print("calling clip interrogator")
29
  #prompt = img_to_text(uploaded_image, "ViT-L (best for Stable Diffusion 1.*)", "fast", fn_index=1)[0]
30
  prompt = img_to_text(uploaded_image, 'fast', 4, fn_index=1)[0]
31
  print(prompt)
32
  pat = get_pat_token()
33
+ #music_result = get_music(pat, prompt, track_duration, gen_intensity, gen_mode)
34
+ music_result = generate_track_by_prompt(pat, prompt, track_duration, gen_intensity, gen_mode)
35
  #print(pat)
36
  return music_result, gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
37
 
38
+ from utils import get_tags_for_prompts, get_mubert_tags_embedding
39
+
40
 
 
 
41
 
42
  def get_pat_token():
43
  r = httpx.post('https://api-b2b.mubert.com/v2/GetServiceAccess',
 
109
  time.sleep(1)
110
 
111
 
112
+ def generate_track_by_prompt(pat, prompt, duration, gen_intensity, gen_mode):
113
  try:
 
114
  _, tags = get_tags_for_prompts(minilm, mubert_tags_embeddings, [prompt, ])[0]
115
  result = get_track_by_tags(tags, pat, int(duration), gen_intensity, gen_mode)
116
  print(result)