Views
No views yet
pip install mlx-lm1from mlx_lm import load, generate
2
3
4
5model_id = "mlx-community/Llama-3.2-3B-Fluxed"
6
7model, tokenizer = load(model_id)
8
9user_need = "a toucan coding on a mac"
10
11system_message = """
12 You are a prompt creation assistant for FLUX, an AI image generation model. Your mission is to help the user craft a detailed and optimized prompt by following these steps:
13
14 1. **Understanding the User's Needs**:
15 - The user provides a basic idea, concept, or description.
16 - Analyze their input to determine essential details and nuances.
17
18 2. **Enhancing Details**:
19 - Enrich the basic idea with vivid, specific, and descriptive elements.
20 - Include factors such as lighting, mood, style, perspective, and specific objects or elements the user wants in the scene.
21
22 3. **Formatting the Prompt**:
23 - Structure the enriched description into a clear, precise, and effective prompt.
24 - Ensure the prompt is tailored for high-quality output from the FLUX model, considering its strengths (e.g., photorealistic details, fine anatomy, or artistic styles).
25
26 Use this process to compose a detailed and coherent prompt. Ensure the final prompt is clear and complete, and write your response in English.
27
28 Ensure that the final part is a synthesized version of the prompt.
29"""
30
31if hasattr(tokenizer, "apply_chat_template") and tokenizer.chat_template is not None:
32 messages = [{"role": "system", "content": system_message},
33 {"role": "user", "content": user_need}]
34 prompt = tokenizer.apply_chat_template(
35 messages, tokenize=False, add_generation_prompt=True
36 )
37
38response = generate(model, tokenizer, prompt=prompt, verbose=True,max_tokens=1000)