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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -5
app.py CHANGED
@@ -60,13 +60,14 @@ def calculate_engagement_increase():
60
 
61
  # Function to load and plot the masterpiece data (video and graph)
62
  def load_masterpiece_video_and_plot():
63
- masterpiece_video_path = download_file_from_repo("starperformer_viral.mp4") # Download video from Hugging Face
64
-
65
- # Replace [actual outcome] with the correct label
66
- actual_outcome = extract_prediction_label_from_masterpiece(masterpiece_video_path)
 
67
 
68
  # Load the data for the TikTok graph (simulated example)
69
- tiktok_csv_path = download_file_from_repo("tiktok_histogram.csv") # Download CSV from Hugging Face
70
  df = pd.read_csv(tiktok_csv_path)
71
 
72
  # Assuming the CSV has columns 'Engagement' and 'Density'
@@ -86,6 +87,24 @@ def load_masterpiece_video_and_plot():
86
  # Return the video path and graph
87
  return masterpiece_video_path, fig
88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  # Create the Gradio interface
90
  with gr.Blocks() as dashboard:
91
 
 
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'
 
87
  # Return the video path and graph
88
  return masterpiece_video_path, fig
89
 
90
+ # Function to highlight the quintile based on prediction label for the masterpiece
91
+ def highlight_masterpiece_quintile(fig, actual_outcome, x_max):
92
+ label_map = {"normal": 1, "good": 2, "very good": 3, "exceptional": 4, "viral": 5}
93
+ quintile = label_map.get(actual_outcome.lower(), 1)
94
+
95
+ # Dynamically adjust the x0 and x1 ranges based on x_max
96
+ quintile_width = x_max / 5 # Divide x_max into 5 quintiles
97
+ x0 = (quintile - 1) * quintile_width
98
+ x1 = quintile * quintile_width
99
+
100
+ # Add a shaded region in the graph corresponding to the quintile
101
+ fig.add_vrect(
102
+ x0=x0, x1=x1,
103
+ fillcolor="green", opacity=0.25, line_width=0,
104
+ annotation_text=f"Actual Outcome: {actual_outcome.capitalize()}"
105
+ )
106
+ return fig
107
+
108
  # Create the Gradio interface
109
  with gr.Blocks() as dashboard:
110