Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
-
|
2 |
import os
|
3 |
import gradio as gr
|
4 |
from transformers import pipeline
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
13 |
|
14 |
def generate_text(prompt):
|
15 |
"""Generate text based on the input prompt using the loaded NLP model."""
|
@@ -28,7 +28,7 @@ iface = gr.Interface(
|
|
28 |
inputs=gr.Textbox(lines=2, placeholder="Enter your text here..."),
|
29 |
outputs="text",
|
30 |
title="Text Generation with Falcon Model",
|
31 |
-
description="Enter some text and see how the Falcon model continues it!"
|
32 |
)
|
33 |
|
34 |
# Essential for Hugging Face Spaces
|
|
|
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
from transformers import pipeline
|
4 |
+
|
5 |
+
# Initialize the model
|
6 |
+
try:
|
7 |
+
model_name = "tiiuae/falcon-40b-instruct" # Ensure this is the correct model name
|
8 |
+
nlp_model = pipeline('text-generation', model=model_name)
|
9 |
+
print("Model loaded successfully.")
|
10 |
+
except Exception as e:
|
11 |
+
nlp_model = None
|
12 |
+
print(f"Failed to load model: {str(e)}")
|
13 |
|
14 |
def generate_text(prompt):
|
15 |
"""Generate text based on the input prompt using the loaded NLP model."""
|
|
|
28 |
inputs=gr.Textbox(lines=2, placeholder="Enter your text here..."),
|
29 |
outputs="text",
|
30 |
title="Text Generation with Falcon Model",
|
31 |
+
description="Enter some text and see how the Falcon model continues it! This model automatically generates text based on the input provided. Try it out!"
|
32 |
)
|
33 |
|
34 |
# Essential for Hugging Face Spaces
|