Views
No views yet
"A golden retriever playing in a park, chasing butterflies on a sunny afternoon""# SUNSHINE AND PLEASURE - [Scene: A golden retriever runs through a sunlit park, bounding after fluttering butterflies. Grass sways in gentle breeze.] - Camera: Tracking shot at ground level, capturing playful motion and joyful expression. Cut to wide view showing expanse of green. - Lighting: Bright sunlight with long shadows. Golden hour glow enhances fur texture. - Motion: Dog leaps gracefully, tail wagging wildly. Butterflies dance around nose. - Details: Ribbon on collar; muddy paws. Birds chirp in trees. - Atmosphere: Innocence, freedom, pure happiness. - Style: Whimsical nature documentary. Inspired by Up and Finding Nemo. - Color Grading: Warm tones with high saturation. Add soft focus and subtle vignette. - Sound Design: Puppy barks, laughter, and rustling leaves."pip install torch==2.1.0 transformers==4.42.4 peft==0.11.11import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3from peft import PeftModel
4
5base_model_id = "Qwen/Qwen2.5-14B-Instruct"
6adapter_id = "dariakryvosheieva/video-prompt-enhancer"
7
8tokenizer = AutoTokenizer.from_pretrained(adapter_id, use_fast=True)
9if tokenizer.pad_token is None:
10 tokenizer.pad_token = tokenizer.eos_token
11
12base = AutoModelForCausalLM.from_pretrained(
13 base_model_id, device_map="auto", torch_dtype="auto"
14)
15model = PeftModel.from_pretrained(base, adapter_id).eval()
16
17
18def format_query(simple_prompt: str) -> str:
19 instruction_text = (
20 "Convert the following video generation prompt into a professional-grade prompt that will produce a high quality, aesthetic, and impressive video."
21 "If the original prompt includes a style specification (such as 'anime', 'pixel', or 'cartoon'), keep it in the converted prompt."
22 "Output only the converted prompt."
23 )
24 return f"{instruction_text}\n\nInput:\n{simple_prompt.strip()}\n\nOutput:\n"
25
26
27prompt = "a cat riding a skateboard in a park at sunset"
28text = format_query(prompt)
29inputs = tokenizer(text, return_tensors="pt").to(model.device)
30
31with torch.no_grad():
32 out = model.generate(
33 **inputs,
34 max_new_tokens=256,
35 temperature=0.7,
36 top_p=0.95,
37 pad_token_id=tokenizer.pad_token_id,
38 )
39
40print(
41 tokenizer.decode(out[0][inputs["input_ids"].shape[-1] :], skip_special_tokens=True)
42)