Update app.py
Browse files
app.py
CHANGED
@@ -1,20 +1,13 @@
|
|
1 |
import pandas as pd
|
2 |
from transformers import pipeline
|
3 |
-
from google.colab import files # Only needed if running in Google Colab
|
4 |
|
5 |
# Function to enhance title using Hugging Face model
|
6 |
def generate_title_with_huggingface(description):
|
7 |
result = generator(description, max_length=100, num_return_sequences=1)
|
8 |
return result[0]['generated_text']
|
9 |
|
10 |
-
#
|
11 |
-
#
|
12 |
-
uploaded = files.upload()
|
13 |
-
|
14 |
-
# Assuming the file name is 'output.csv' after upload
|
15 |
-
file_name = list(uploaded.keys())[0]
|
16 |
-
|
17 |
-
# Load the CSV file
|
18 |
df = pd.read_csv(file_name)
|
19 |
|
20 |
# Initialize the text generation model (e.g., GPT-2)
|
@@ -35,5 +28,5 @@ df['Keywords'] = df['Description'].apply(generate_keywords)
|
|
35 |
seo_output_file_path = 'seo_huggingface_filename_title_keywords.csv'
|
36 |
df[['Filename', 'Title', 'Keywords']].to_csv(seo_output_file_path, index=False)
|
37 |
|
38 |
-
#
|
39 |
-
|
|
|
1 |
import pandas as pd
|
2 |
from transformers import pipeline
|
|
|
3 |
|
4 |
# Function to enhance title using Hugging Face model
|
5 |
def generate_title_with_huggingface(description):
|
6 |
result = generator(description, max_length=100, num_return_sequences=1)
|
7 |
return result[0]['generated_text']
|
8 |
|
9 |
+
# Load the CSV file directly (replace 'input.csv' with your actual file path)
|
10 |
+
file_name = 'input.csv' # Update this with the correct path to your CSV file
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
df = pd.read_csv(file_name)
|
12 |
|
13 |
# Initialize the text generation model (e.g., GPT-2)
|
|
|
28 |
seo_output_file_path = 'seo_huggingface_filename_title_keywords.csv'
|
29 |
df[['Filename', 'Title', 'Keywords']].to_csv(seo_output_file_path, index=False)
|
30 |
|
31 |
+
# The output file will be saved in the current working directory
|
32 |
+
print(f"File saved as {seo_output_file_path}")
|