SpyC0der77 commited on
Commit
c7f0abc
·
verified ·
1 Parent(s): 401f757

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -1
app.py CHANGED
@@ -6,7 +6,21 @@ client = InferenceClient("EvanZhouDev/open-genmoji", token=os.getenv("HUGGINGFAC
6
 
7
  # Define the process function that takes a text prompt and returns an image
8
  def process(prompt):
9
- image = client.text_to_image(prompt)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  return image
11
 
12
  # Create a Gradio Blocks app
 
6
 
7
  # Define the process function that takes a text prompt and returns an image
8
  def process(prompt):
9
+ messages = [
10
+ { "role": "system", "content": "You are helping create a prompt for a Emoji generation image model. An emoji must be easily interpreted when small so details must be exaggerated to be clear. Your goal is to use descriptions to achieve this.\n\nYou will receive a user description, and you must rephrase it to consist of short phrases separated by periods, adding detail to everything the user provides.\n\nAdd describe the color of all parts or components of the emoji. Unless otherwise specified by the user, do not describe people. Do not describe the background of the image. Your output should be in the format:\n\n```\nemoji of {description}. {addon phrases}. 3D lighting. no cast shadows.\n```\n\nThe description should be a 1 sentence of your interpretation of the emoji.\nThen, you may choose to add addon phrases. You must use the following in the given scenarios:\n\n- \"cute.\": If generating anything that's not an object, and also not a human\n- \"enlarged head in cartoon style.\": ONLY animals\n- \"head is turned towards viewer.\": ONLY humans or animals\n- \"detailed texture.\": ONLY objects\n\nFurther addon phrases may be added to ensure the clarity of the emoji." },
11
+ { "role": "user", "content": prompt }
12
+ ]
13
+
14
+ completion = client.chat.completions.create(
15
+ model="Qwen/Qwen2.5-72B-Instruct",
16
+ messages=messages,
17
+ temperature=0.5,
18
+ max_tokens=2048,
19
+ top_p=0.7
20
+ )
21
+
22
+ print(completion.choices[0].message)
23
+ image = client.text_to_image(completion.choices[0].message)
24
  return image
25
 
26
  # Create a Gradio Blocks app