Woubit commited on
Commit
8bee074
·
verified ·
1 Parent(s): 48fb91d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -22
app.py CHANGED
@@ -1,22 +1,22 @@
1
- import streamlit as st
2
- import joblib
3
-
4
- # Load the model and vectorizer
5
- model = joblib.load('svm_spam_model.pkl')
6
- vectorizer = joblib.load('vectorizer.pkl')
7
-
8
- st.title("Email Spam Detector 📧")
9
- user_input = st.text_area("Enter email text here:")
10
-
11
- if st.button("Predict"):
12
- if user_input:
13
- # Transform text and predict
14
- data = vectorizer.transform([user_input])
15
- prediction = model.predict(data)
16
-
17
- if prediction[0] == 1:
18
- st.error("🚨 This is a SPAM email.")
19
- else:
20
- st.success("✅ This is a legitimate (Ham) email.")
21
- else:
22
- st.warning("Please enter some text to analyze.")
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load a free pipeline model from Hugging Face
5
+ generator = pipeline("text-generation", model="gpt2")
6
+
7
+ def generate_text(user_input):
8
+ # Process the user input through the AI model
9
+ result = generator(user_input, max_length=50, num_return_sequences=1)
10
+ return result[0]['generated_text']
11
+
12
+ # Build the Gradio interface
13
+ demo = gr.Interface(
14
+ fn=generate_text,
15
+ inputs=gr.Textbox(lines=2, placeholder="Enter a prompt here..."),
16
+ outputs="text",
17
+ title="My First AI Assistant"
18
+ )
19
+
20
+ # Launch the app
21
+ if __name__ == "__main__":
22
+ demo.launch()