Update app.py
Browse files
app.py
CHANGED
@@ -4,20 +4,18 @@ import time
|
|
4 |
# Load the model
|
5 |
model = gr.Interface.load("models/roneneldan/TinyStories-Instruct-33M")
|
6 |
|
7 |
-
#
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
-
#
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
time.sleep(0.05) # Add a small delay between characters
|
16 |
-
print() # Print newline after the text is complete
|
17 |
-
|
18 |
-
# Launch the interface with added options and descriptions
|
19 |
-
model.launch(inputs=additional_input, outputs=additional_output, title="Tiny Stories Generator",
|
20 |
-
description="This model generates creative stories based on the input text provided.",
|
21 |
-
examples=[["Once upon a time..."]],
|
22 |
-
live=False, # Disable live updates to control the typing effect
|
23 |
-
fn=typing_effect) # Use the typing_effect function to display output
|
|
|
4 |
# Load the model
|
5 |
model = gr.Interface.load("models/roneneldan/TinyStories-Instruct-33M")
|
6 |
|
7 |
+
# Simulate the typing effect
|
8 |
+
def simulate_typing(input_text):
|
9 |
+
typing_speed = 0.05 # Adjust the speed of typing
|
10 |
+
generated_text = model.predict(input_text)
|
11 |
+
for char in generated_text:
|
12 |
+
time.sleep(typing_speed)
|
13 |
+
# Update the text display area in the Android app with each character
|
14 |
+
# You'll need to implement this part in your Android app using appropriate methods.
|
15 |
+
# For example, you can update the TextView in Android with the new character.
|
16 |
+
return generated_text
|
17 |
|
18 |
+
# Launch the interface
|
19 |
+
gr.Interface(fn=simulate_typing, inputs=gr.inputs.Textbox(label="Input Text", placeholder="Enter your story here..."),
|
20 |
+
outputs=gr.outputs.Textbox(label="Generated Story"), title="Tiny Stories Generator",
|
21 |
+
description="This model generates creative stories based on the input text provided.").launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|