CR7CAD commited on
Commit
6f17888
·
verified ·
1 Parent(s): b2cad31

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -17
app.py CHANGED
@@ -12,27 +12,12 @@ def img2text(image_path):
12
 
13
  # text2story
14
  def text2story(text):
15
- messages = [
16
- {"role": "user", "content": "Who are you?"},
17
- ]
18
  # Using a smaller text generation model
19
- generator = pipeline("text-generation", model="mlx-community/Llama-3.2-1B-Instruct-4bit")
20
- generator(messages)
21
 
22
  # Create a prompt for the story generation
23
  prompt = f"Write a fun children's story based on this: {text}. Once upon a time, "
24
-
25
- # Generate the story
26
- story_result = generator(
27
- prompt,
28
- max_length=200,
29
- num_return_sequences=1,
30
- temperature=0.8,
31
- top_k=50,
32
- top_p=0.95,
33
- do_sample=True
34
- )
35
-
36
  # Extract the generated text
37
  story_text = story_result[0]['generated_text']
38
  story_text = story_text.replace(prompt, "Once upon a time, ")
 
12
 
13
  # text2story
14
  def text2story(text):
 
 
 
15
  # Using a smaller text generation model
16
+ generator = pipeline("text-generation", model="TinyLlama/TinyLlama-1.1B-Chat-v1.0")
 
17
 
18
  # Create a prompt for the story generation
19
  prompt = f"Write a fun children's story based on this: {text}. Once upon a time, "
20
+
 
 
 
 
 
 
 
 
 
 
 
21
  # Extract the generated text
22
  story_text = story_result[0]['generated_text']
23
  story_text = story_text.replace(prompt, "Once upon a time, ")