Munaf1987 commited on
Commit
4bbe186
·
verified ·
1 Parent(s): f2b348b

Update scene_planner.py

Browse files
Files changed (1) hide show
  1. scene_planner.py +5 -7
scene_planner.py CHANGED
@@ -1,20 +1,18 @@
 
1
  from transformers import pipeline
2
 
3
- scene_splitter = pipeline("text2text-generation", model="mistralai/Mistral-7B-Instruct-v0.1")
4
 
5
  def plan_scenes(script):
6
  prompt = (
7
- "Split the following story into 10-15 scenes. For each scene, return a JSON with 'prompt' "
8
- "(scene image description) and 'dialogue' (narration to speak). Make the prompt cartoon-friendly.\nStory:\n" + script
9
  )
10
-
11
  response = scene_splitter(prompt, max_new_tokens=1024, do_sample=False)[0]['generated_text']
12
 
13
  try:
14
  import json
15
  scenes = json.loads(response)
16
  except:
17
- scenes = [
18
- {"prompt": line.strip(), "dialogue": line.strip()} for line in script.split(".") if line.strip()
19
- ]
20
  return scenes[:15]
 
1
+ # In scene_planner.py
2
  from transformers import pipeline
3
 
4
+ scene_splitter = pipeline("text-generation", model="microsoft/phi-2")
5
 
6
  def plan_scenes(script):
7
  prompt = (
8
+ "Split this story into 10-15 cartoon scenes. Each should have a JSON with 'prompt' (image description) "
9
+ "and 'dialogue' (line of narration). Make it suitable for animation.\nStory:\n" + script
10
  )
 
11
  response = scene_splitter(prompt, max_new_tokens=1024, do_sample=False)[0]['generated_text']
12
 
13
  try:
14
  import json
15
  scenes = json.loads(response)
16
  except:
17
+ scenes = [{"prompt": line.strip(), "dialogue": line.strip()} for line in script.split('.') if line.strip()]
 
 
18
  return scenes[:15]