Spaces:
Running
Running
HfApiModel->TransformersModel
Browse files
app.py
CHANGED
@@ -55,7 +55,7 @@ def create_prompt_for_image_generation(user_prompt: str) -> str:
|
|
55 |
6. Output Settings: Suggest aspect ratio, output format (e.g., PNG), quality level, and seed for reproducibility.
|
56 |
Ensure that the generated prompt is logical, descriptive, and written in natural language to maximize compatibility with FLUX-Schnell capabilities.
|
57 |
Example Input:
|
58 |
-
An image of a serene forest with a small cabin.
|
59 |
Example Output:
|
60 |
In the foreground, a lush green forest floor covered with moss and scattered wildflowers.
|
61 |
In the middle ground, a cozy wooden cabin with smoke gently rising from its chimney.
|
@@ -66,21 +66,31 @@ def create_prompt_for_image_generation(user_prompt: str) -> str:
|
|
66 |
capturing golden hour lighting for soft shadows and warm highlights.
|
67 |
The aspect ratio is 1:1, using seed 42 for reproducibility.
|
68 |
"""
|
69 |
-
model = HfApiModel(
|
70 |
-
max_tokens=512,
|
71 |
-
temperature=1.0,
|
72 |
-
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
|
73 |
-
custom_role_conversions=None,
|
|
|
|
|
|
|
|
|
74 |
)
|
|
|
75 |
prompt = prefix + user_prompt + '. ' + postfix
|
|
|
|
|
76 |
try:
|
77 |
-
response = model
|
78 |
-
|
79 |
-
|
|
|
|
|
80 |
|
81 |
except Exception as e:
|
82 |
return f"Error during LLM call: {str(e)}"
|
83 |
|
|
|
84 |
final_answer = FinalAnswerTool()
|
85 |
|
86 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
|
|
55 |
6. Output Settings: Suggest aspect ratio, output format (e.g., PNG), quality level, and seed for reproducibility.
|
56 |
Ensure that the generated prompt is logical, descriptive, and written in natural language to maximize compatibility with FLUX-Schnell capabilities.
|
57 |
Example Input:
|
58 |
+
An image of a serene forest with a small cabin.
|
59 |
Example Output:
|
60 |
In the foreground, a lush green forest floor covered with moss and scattered wildflowers.
|
61 |
In the middle ground, a cozy wooden cabin with smoke gently rising from its chimney.
|
|
|
66 |
capturing golden hour lighting for soft shadows and warm highlights.
|
67 |
The aspect ratio is 1:1, using seed 42 for reproducibility.
|
68 |
"""
|
69 |
+
# model = HfApiModel(
|
70 |
+
# max_tokens=512,
|
71 |
+
# temperature=1.0,
|
72 |
+
# model_id='Qwen/Qwen2.5-Coder-32B-Instruct',
|
73 |
+
# custom_role_conversions=None,
|
74 |
+
# )
|
75 |
+
engine = TransformersModel(
|
76 |
+
model_id="Qwen/Qwen2.5-Coder-32B-Instruct",
|
77 |
+
max_new_tokens=512,
|
78 |
)
|
79 |
+
|
80 |
prompt = prefix + user_prompt + '. ' + postfix
|
81 |
+
messages = [{"role": "user", "content": prompt}]
|
82 |
+
|
83 |
try:
|
84 |
+
# response = model(
|
85 |
+
# prompt=prompt, temperature=1., max_tokens=512)
|
86 |
+
response = engine(messages, stop_sequences=["END"])
|
87 |
+
# return response['choices'][0]['text']
|
88 |
+
return response
|
89 |
|
90 |
except Exception as e:
|
91 |
return f"Error during LLM call: {str(e)}"
|
92 |
|
93 |
+
|
94 |
final_answer = FinalAnswerTool()
|
95 |
|
96 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|