fffiloni commited on
Commit
aef38d7
1 Parent(s): ce8828d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -20
app.py CHANGED
@@ -73,22 +73,12 @@ from transformers import pipeline
73
  pipe = pipeline("text-generation", model="HuggingFaceH4/zephyr-7b-beta", torch_dtype=torch.bfloat16, device_map="auto")
74
 
75
  agent_maker_sys = f"""
76
- You are an AI whose job is to help users create their own chatbot whose personality will reflect the character or scene from an image described by users.
77
- In particular, you need to respond succintly in a friendly tone, write a system prompt for an LLM, a catchy title for the chatbot, and a very short example user input. Make sure each part is included.
78
- The system prompt will not mention any image provided.
79
-
80
- For example, if a user says, "a picture of a man in a black suit and tie riding a black dragon", first do a friendly response, then add the title, system prompt, and example user input.
81
- Immediately STOP after the example input. It should be EXACTLY in this format:
82
- "Sure, I'd be happy to help you build a bot! I'm generating a title, system prompt, and an example input. How do they sound?
83
- Title: Dragon Trainer
84
- System prompt: Let's say You are a Dragon trainer and your job is to provide guidance and tips on mastering dragons. Use a friendly and informative tone.
85
- Example input: How can I train a dragon to breathe fire?"
86
-
87
- Here's another example. If a user types, "In the image, there is a drawing of a man in a red suit sitting at a dining table. He is smoking a cigarette, which adds a touch of sophistication to his appearance.", respond:
88
- "Sure, I'd be happy to help you build a bot! I'm generating a title, system prompt, and an example input. How do they sound?
89
- Title: Gentleman's Companion
90
- System prompt: Let's say You are sophisticated old man, also know as the Gentleman's Companion. As an LLM, your job is to provide recommendations for fine dining, cocktails, and cigar brands based on your preferences. Use a sophisticated and refined tone.
91
- Example input: Can you suggest a good cigar brand for a man who enjoys smoking while dining in style?"
92
  """
93
 
94
  instruction = f"""
@@ -111,12 +101,12 @@ def infer(image_in):
111
  pattern = r'\<\|system\|\>(.*?)\<\|assistant\|\>'
112
  cleaned_text = re.sub(pattern, '', outputs[0]["generated_text"], flags=re.DOTALL)
113
 
114
- print(f"SUGGESTED LLM: {cleaned_text}")
115
 
116
  return user_prompt, cleaned_text.lstrip("\n")
117
 
118
- title = f"LLM Agent from a Picture",
119
- description = f"Get a LLM system prompt from a picture so you can use it in <a href='https://huggingface.co/spaces/abidlabs/GPT-Baker'>GPT-Baker</a>."
120
 
121
  css = """
122
  #col-container{
@@ -129,7 +119,7 @@ css = """
129
  with gr.Blocks(css=css) as demo:
130
  with gr.Column(elem_id="col-container"):
131
  gr.HTML(f"""
132
- <h2 style="text-align: center;">LLM Agent from a Picture</h2>
133
  <p style="text-align: center;">{description}</p>
134
  """)
135
 
 
73
  pipe = pipeline("text-generation", model="HuggingFaceH4/zephyr-7b-beta", torch_dtype=torch.bfloat16, device_map="auto")
74
 
75
  agent_maker_sys = f"""
76
+ 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.
77
+ In particular, you need to respond succintly in a friendly tone, write a musical prompt for an music generation model.
78
+
79
+ For example, if a user says, "a picture of a man in a black suit and tie riding a black dragon", provide immediately a musical prompt corresponding to the image description.
80
+ Immediately STOP after that. It should be EXACTLY in this format:
81
+ "A grand orchestral arrangement with thunderous percussion, epic brass fanfares, and soaring strings, creating a cinematic atmosphere fit for a heroic battle"
 
 
 
 
 
 
 
 
 
 
82
  """
83
 
84
  instruction = f"""
 
101
  pattern = r'\<\|system\|\>(.*?)\<\|assistant\|\>'
102
  cleaned_text = re.sub(pattern, '', outputs[0]["generated_text"], flags=re.DOTALL)
103
 
104
+ print(f"SUGGESTED Musical prompt: {cleaned_text}")
105
 
106
  return user_prompt, cleaned_text.lstrip("\n")
107
 
108
+ title = "Image to Music V2",
109
+ description = "Get music from a picture"
110
 
111
  css = """
112
  #col-container{
 
119
  with gr.Blocks(css=css) as demo:
120
  with gr.Column(elem_id="col-container"):
121
  gr.HTML(f"""
122
+ <h2 style="text-align: center;">{title}</h2>
123
  <p style="text-align: center;">{description}</p>
124
  """)
125