Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -33,7 +33,7 @@ lemmatizer = WordNetLemmatizer()
|
|
| 33 |
# Load models (cache them to avoid reloading on every interaction)
|
| 34 |
@st.cache_resource
|
| 35 |
def load_classification_model():
|
| 36 |
-
model_name = "Imasha17/News_classification.
|
| 37 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 38 |
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
| 39 |
return pipeline("text-classification", model=model, tokenizer=tokenizer)
|
|
@@ -153,7 +153,7 @@ with tab1:
|
|
| 153 |
else:
|
| 154 |
df = pd.read_csv(uploaded_file)
|
| 155 |
# Load the fine-tuned news classifier
|
| 156 |
-
classifier = pipeline("text-classification", model="Imasha17/News_classification.
|
| 157 |
|
| 158 |
# Preprocessing steps
|
| 159 |
df["cleaned_content"] = df["content"].str.lower()
|
|
@@ -212,18 +212,20 @@ with tab1:
|
|
| 212 |
|
| 213 |
# Keep only necessary columns
|
| 214 |
df = df[['content','Class']]
|
| 215 |
-
|
|
|
|
| 216 |
st.subheader("Preview Uploaded Data")
|
| 217 |
st.dataframe(df.head(5))
|
| 218 |
|
| 219 |
-
|
| 220 |
st.subheader("Classification Results")
|
| 221 |
st.write(df)
|
| 222 |
|
| 223 |
st.subheader("Class Distribution")
|
| 224 |
class_dist = df['Class'].value_counts()
|
| 225 |
st.bar_chart(class_dist)
|
| 226 |
-
|
|
|
|
| 227 |
st.subheader("Download Results")
|
| 228 |
csv = df.to_csv(index=False).encode('utf-8')
|
| 229 |
st.download_button(
|
|
|
|
| 33 |
# Load models (cache them to avoid reloading on every interaction)
|
| 34 |
@st.cache_resource
|
| 35 |
def load_classification_model():
|
| 36 |
+
model_name = "Imasha17/News_classification.4" # Replace with your model path
|
| 37 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 38 |
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
| 39 |
return pipeline("text-classification", model=model, tokenizer=tokenizer)
|
|
|
|
| 153 |
else:
|
| 154 |
df = pd.read_csv(uploaded_file)
|
| 155 |
# Load the fine-tuned news classifier
|
| 156 |
+
classifier = pipeline("text-classification", model="Imasha17/News_classification.4")
|
| 157 |
|
| 158 |
# Preprocessing steps
|
| 159 |
df["cleaned_content"] = df["content"].str.lower()
|
|
|
|
| 212 |
|
| 213 |
# Keep only necessary columns
|
| 214 |
df = df[['content','Class']]
|
| 215 |
+
|
| 216 |
+
#Preview Uploaded Data
|
| 217 |
st.subheader("Preview Uploaded Data")
|
| 218 |
st.dataframe(df.head(5))
|
| 219 |
|
| 220 |
+
#show Classification Results
|
| 221 |
st.subheader("Classification Results")
|
| 222 |
st.write(df)
|
| 223 |
|
| 224 |
st.subheader("Class Distribution")
|
| 225 |
class_dist = df['Class'].value_counts()
|
| 226 |
st.bar_chart(class_dist)
|
| 227 |
+
|
| 228 |
+
#download csv file
|
| 229 |
st.subheader("Download Results")
|
| 230 |
csv = df.to_csv(index=False).encode('utf-8')
|
| 231 |
st.download_button(
|