conhllnd commited on
Commit
d3e0248
·
verified ·
1 Parent(s): f06dd7b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -11
app.py CHANGED
@@ -4,7 +4,7 @@ from huggingface_hub import hf_hub_download
4
  import os
5
 
6
  # Hugging Face API token and repo setup
7
- hf_token = os.getenv("hfkeymeow") # Make sure your token is correctly stored
8
  repo_id = "conhllnd/Playper-V2" # Repository ID on Hugging Face
9
  repo_type = "space" # Repository type
10
 
@@ -57,17 +57,16 @@ def calculate_engagement_increase():
57
 
58
  return f"Leonardo got you {int(engagement_increase)} more engagements across TikTok & Facebook!"
59
 
60
-
61
  # Function to load and plot the masterpiece data (video and graph)
62
  def load_masterpiece_video_and_plot():
63
  # Download the video file from the Hugging Face repository
64
- masterpiece_video_path = hf_hub_download(repo_id="conhllnd/Playper-V2", filename="starperformer_viral.mp4", repo_type="space")
65
 
66
  # Replace [actual outcome] with the correct label (here it's 'viral' from the filename)
67
  actual_outcome = "viral"
68
 
69
- # Load the data for the TikTok graph (simulated example)
70
- tiktok_csv_path = hf_hub_download(repo_id="conhllnd/Playper-V2", filename="tiktok_histogram.csv", repo_type="space")
71
  df = pd.read_csv(tiktok_csv_path)
72
 
73
  # Assuming the CSV has columns 'Engagement' and 'Density'
@@ -141,19 +140,19 @@ with gr.Blocks() as dashboard:
141
  # Section for TikTok projections (Videos)
142
  with gr.Row():
143
  with gr.Column():
144
- video_path_1, graph_1 = load_data_and_plot("video", "TikTok1", tiktok_csv_path, video_folder)
145
  if video_path_1:
146
  gr.Video(video_path_1, label="TikTok 1 Video")
147
  gr.Plot(graph_1, label="TikTok 1 Performance")
148
 
149
  with gr.Column():
150
- video_path_2, graph_2 = load_data_and_plot("video", "TikTok2", tiktok_csv_path, video_folder)
151
  if video_path_2:
152
  gr.Video(video_path_2, label="TikTok 2 Video")
153
  gr.Plot(graph_2, label="TikTok 2 Performance")
154
 
155
  with gr.Column():
156
- video_path_3, graph_3 = load_data_and_plot("video", "TikTok3", tiktok_csv_path, video_folder)
157
  if video_path_3:
158
  gr.Video(video_path_3, label="TikTok 3 Video")
159
  gr.Plot(graph_3, label="TikTok 3 Performance")
@@ -161,19 +160,19 @@ with gr.Blocks() as dashboard:
161
  # Section for Facebook projections (Statics)
162
  with gr.Row():
163
  with gr.Column():
164
- image_path_1, graph_4 = load_data_and_plot("image", "Static1", facebook_csv_path, image_folder)
165
  if image_path_1:
166
  gr.Image(image_path_1, label="Facebook Static 1")
167
  gr.Plot(graph_4, label="Facebook Static 1 Performance")
168
 
169
  with gr.Column():
170
- image_path_2, graph_5 = load_data_and_plot("image", "Static2", facebook_csv_path, image_folder)
171
  if image_path_2:
172
  gr.Image(image_path_2, label="Facebook Static 2")
173
  gr.Plot(graph_5, label="Facebook Static 2 Performance")
174
 
175
  with gr.Column():
176
- image_path_3, graph_6 = load_data_and_plot("image", "Static3", facebook_csv_path, image_folder)
177
  if image_path_3:
178
  gr.Image(image_path_3, label="Facebook Static 3")
179
  gr.Plot(graph_6, label="Facebook Static 3 Performance")
 
4
  import os
5
 
6
  # Hugging Face API token and repo setup
7
+ hf_token = os.getenv("hfkeymeow") # Ensure your token is correctly stored
8
  repo_id = "conhllnd/Playper-V2" # Repository ID on Hugging Face
9
  repo_type = "space" # Repository type
10
 
 
57
 
58
  return f"Leonardo got you {int(engagement_increase)} more engagements across TikTok & Facebook!"
59
 
 
60
  # Function to load and plot the masterpiece data (video and graph)
61
  def load_masterpiece_video_and_plot():
62
  # Download the video file from the Hugging Face repository
63
+ masterpiece_video_path = download_file_from_repo("starperformer_viral.mp4")
64
 
65
  # Replace [actual outcome] with the correct label (here it's 'viral' from the filename)
66
  actual_outcome = "viral"
67
 
68
+ # Load the data for the TikTok graph
69
+ tiktok_csv_path = download_file_from_repo("tiktok_histogram.csv")
70
  df = pd.read_csv(tiktok_csv_path)
71
 
72
  # Assuming the CSV has columns 'Engagement' and 'Density'
 
140
  # Section for TikTok projections (Videos)
141
  with gr.Row():
142
  with gr.Column():
143
+ video_path_1, graph_1 = load_data_and_plot("video", "TikTok1", download_file_from_repo("tiktok_histogram.csv"), download_file_from_repo("video_folder"))
144
  if video_path_1:
145
  gr.Video(video_path_1, label="TikTok 1 Video")
146
  gr.Plot(graph_1, label="TikTok 1 Performance")
147
 
148
  with gr.Column():
149
+ video_path_2, graph_2 = load_data_and_plot("video", "TikTok2", download_file_from_repo("tiktok_histogram.csv"), download_file_from_repo("video_folder"))
150
  if video_path_2:
151
  gr.Video(video_path_2, label="TikTok 2 Video")
152
  gr.Plot(graph_2, label="TikTok 2 Performance")
153
 
154
  with gr.Column():
155
+ video_path_3, graph_3 = load_data_and_plot("video", "TikTok3", download_file_from_repo("tiktok_histogram.csv"), download_file_from_repo("video_folder"))
156
  if video_path_3:
157
  gr.Video(video_path_3, label="TikTok 3 Video")
158
  gr.Plot(graph_3, label="TikTok 3 Performance")
 
160
  # Section for Facebook projections (Statics)
161
  with gr.Row():
162
  with gr.Column():
163
+ image_path_1, graph_4 = load_data_and_plot("image", "Static1", download_file_from_repo("facebook_histogram.csv"), download_file_from_repo("image_folder"))
164
  if image_path_1:
165
  gr.Image(image_path_1, label="Facebook Static 1")
166
  gr.Plot(graph_4, label="Facebook Static 1 Performance")
167
 
168
  with gr.Column():
169
+ image_path_2, graph_5 = load_data_and_plot("image", "Static2", download_file_from_repo("facebook_histogram.csv"), download_file_from_repo("image_folder"))
170
  if image_path_2:
171
  gr.Image(image_path_2, label="Facebook Static 2")
172
  gr.Plot(graph_5, label="Facebook Static 2 Performance")
173
 
174
  with gr.Column():
175
+ image_path_3, graph_6 = load_data_and_plot("image", "Static3", download_file_from_repo("facebook_histogram.csv"), download_file_from_repo("image_folder"))
176
  if image_path_3:
177
  gr.Image(image_path_3, label="Facebook Static 3")
178
  gr.Plot(graph_6, label="Facebook Static 3 Performance")