Xianbao QIAN commited on
Commit
fcf3b2b
·
2 Parent(s): 0265aac e4c1ec6

Merge branch 'main' of https://huggingface.co/spaces/cfahlgren1/model-release-heatmap into real-master

Browse files
Files changed (1) hide show
  1. src/pages/index.tsx +73 -65
src/pages/index.tsx CHANGED
@@ -1,11 +1,17 @@
1
- "use client";
2
-
3
- import { Inter } from "next/font/google";
4
  import ActivityCalendar from "react-activity-calendar";
5
- import { useState, useEffect } from "react";
6
- import { Tooltip as MuiTooltip } from '@mui/material';
7
-
8
- const inter = Inter({ subsets: ["latin"] });
 
 
 
 
 
 
 
 
9
 
10
  interface ModelData {
11
  createdAt: string;
@@ -18,20 +24,10 @@ interface Activity {
18
  level: number;
19
  }
20
 
21
- export default function Home() {
22
  const [calendarData, setCalendarData] = useState<Record<string, Activity[]>>({});
23
  const [isLoading, setIsLoading] = useState(true);
24
-
25
- const PROVIDERS_MAP: Record<string, { color: string; authors: string[] }> = {
26
- "BAAI": { color: "#FF7000", authors: ["BAAI"] }, // Vibrant Orange
27
- "DeepSeek": { color: "#1877F2", authors: ["deepseek-ai"] }, // Meta's Blue
28
- "Shanghai AI Lab": { color: "#10A37F", authors: ["internlm", "OpenGVLab", "openmmlab", "Vchitect"] }, // Fresh Green
29
- "Alibaba": { color: "#FF6F00", authors: ["Qwen", "Alibaba-NLP", "alibaba-pai", "DAMO-NLP-SG", 'ali-vilab', 'modelscope', 'FunAudioLLM'] }, // Bright Orange
30
- "ZhipuAI / GLM": { color: "#4285F4", authors: ["THUDM"] }, // Classic Blue
31
- "Tencent": { color: "#1DA1F2", authors: ["TencentARC", "Tencent-Hunyuan", "h94"] }, // Twitter Blue
32
- "Yi/01": { color: "#FF4500", authors: ["01-ai"] }, // Orange-Red
33
- "Multimodal Art Projection (m-a-p)": { color: "#5E35B1", authors: ["m-a-p"] } // Dark Purple, with gradient from Very Light Purple to Dark Purple
34
- }
35
 
36
  const generateCalendarData = (modelData: ModelData[]) => {
37
  const data: Record<string, Activity[]> = Object.fromEntries(
@@ -41,18 +37,27 @@ export default function Home() {
41
  const today = new Date();
42
  const startDate = new Date(today);
43
  startDate.setMonth(today.getMonth() - 11);
44
- startDate.setDate(1); // start from the first day of the month
 
 
 
45
 
46
- // generate daily data for each provider
 
 
 
 
 
 
 
 
 
 
47
  for (let d = new Date(startDate); d <= today; d.setDate(d.getDate() + 1)) {
48
  const dateString = d.toISOString().split('T')[0];
49
 
50
- Object.entries(PROVIDERS_MAP).forEach(([provider, { authors }]) => {
51
- const count = modelData.filter(item =>
52
- item.createdAt.startsWith(dateString) &&
53
- authors.some(author => item.id.startsWith(author))
54
- ).length;
55
-
56
  data[provider].push({ date: dateString, count, level: 0 });
57
  });
58
  }
@@ -111,44 +116,47 @@ export default function Home() {
111
  }, []);
112
 
113
  return (
114
- <main className={`flex flex-col items-center justify-center min-h-screen mx-auto p-24 ${inter.className}`}>
115
- <h1 className="text-5xl font-bold text-center">Chinese AI Community: Open Source Heatmap</h1>
116
- <p className="text-center mt-2 text-sm">A heatmap for open source model releases.</p>
117
- <p className="text-center mt-2 text-sm">Huge thanks to Caleb for the excellent original work. <a href="https://huggingface.co/spaces/cfahlgren1/model-release-heatmap" target="_blank">Link</a> to the original repo</p>
118
- <div className="mt-16">
119
- {isLoading ? (
120
- <p>Loading...</p>
121
- ) : (
122
- <>
123
- {Object.entries(PROVIDERS_MAP)
124
- .sort(([keyA], [keyB]) =>
125
- calendarData[keyB].reduce((sum, day) => sum + day.count, 0) -
126
- calendarData[keyA].reduce((sum, day) => sum + day.count, 0)
127
- )
128
- .map(([providerName, { color }]) => (
129
- <div key={providerName} className="mb-8">
130
- <h2 className="text-2xl font-bold mb-2">{providerName}</h2>
131
- <ActivityCalendar
132
- data={calendarData[providerName]}
133
- theme={{
134
- dark: ['#161b22', color],
135
- light: ['#e0e0e0', color],
136
- }}
137
- hideTotalCount
138
- renderBlock={(block, activity) => (
139
- <MuiTooltip
140
- title={`${activity.count} models created on ${activity.date}`}
141
- >
142
- {block}
143
- </MuiTooltip>
144
- )}
145
- />
 
 
 
146
  </div>
147
- ))
148
- }
149
- </>
150
- )}
151
- </div>
152
- </main>
153
  );
154
  }
 
1
+ import React, { useState, useEffect } from 'react';
 
 
2
  import ActivityCalendar from "react-activity-calendar";
3
+ import { Tooltip } from '@mui/material';
4
+
5
+ const PROVIDERS_MAP: Record<string, { color: string; authors: string[] }> = {
6
+ "BAAI": { color: "#FF7000", authors: ["BAAI"] }, // Vibrant Orange
7
+ "DeepSeek": { color: "#1877F2", authors: ["deepseek-ai"] }, // Meta's Blue
8
+ "Shanghai AI Lab": { color: "#10A37F", authors: ["internlm", "OpenGVLab", "openmmlab", "Vchitect"] }, // Fresh Green
9
+ "Alibaba": { color: "#FF6F00", authors: ["Qwen", "Alibaba-NLP", "alibaba-pai", "DAMO-NLP-SG", 'ali-vilab', 'modelscope', 'FunAudioLLM'] }, // Bright Orange
10
+ "ZhipuAI / GLM": { color: "#4285F4", authors: ["THUDM"] }, // Classic Blue
11
+ "Tencent": { color: "#1DA1F2", authors: ["TencentARC", "Tencent-Hunyuan", "h94"] }, // Twitter Blue
12
+ "Yi/01": { color: "#FF4500", authors: ["01-ai"] }, // Orange-Red
13
+ "Multimodal Art Projection (m-a-p)": { color: "#5E35B1", authors: ["m-a-p"] } // Dark Purple, with gradient from Very Light Purple to Dark Purple
14
+ }
15
 
16
  interface ModelData {
17
  createdAt: string;
 
24
  level: number;
25
  }
26
 
27
+ export default function OpenSourceHeatmap() {
28
  const [calendarData, setCalendarData] = useState<Record<string, Activity[]>>({});
29
  const [isLoading, setIsLoading] = useState(true);
30
+
 
 
 
 
 
 
 
 
 
 
31
 
32
  const generateCalendarData = (modelData: ModelData[]) => {
33
  const data: Record<string, Activity[]> = Object.fromEntries(
 
37
  const today = new Date();
38
  const startDate = new Date(today);
39
  startDate.setMonth(today.getMonth() - 11);
40
+ startDate.setDate(1);
41
+
42
+ // create a map to store counts for each provider and date
43
+ const countMap: Record<string, Record<string, number>> = {};
44
 
45
+ modelData.forEach(item => {
46
+ const dateString = item.createdAt.split('T')[0];
47
+ Object.entries(PROVIDERS_MAP).forEach(([provider, { authors }]) => {
48
+ if (authors.some(author => item.id.startsWith(author))) {
49
+ countMap[provider] = countMap[provider] || {};
50
+ countMap[provider][dateString] = (countMap[provider][dateString] || 0) + 1;
51
+ }
52
+ });
53
+ });
54
+
55
+ // fill in with 0s for days with no activity
56
  for (let d = new Date(startDate); d <= today; d.setDate(d.getDate() + 1)) {
57
  const dateString = d.toISOString().split('T')[0];
58
 
59
+ Object.entries(PROVIDERS_MAP).forEach(([provider]) => {
60
+ const count = countMap[provider]?.[dateString] || 0;
 
 
 
 
61
  data[provider].push({ date: dateString, count, level: 0 });
62
  });
63
  }
 
116
  }, []);
117
 
118
  return (
119
+ <div className="w-full max-w-screen-lg mx-auto p-4">
120
+ <h1 className="text-3xl lg:text-5xl mt-16 font-bold text-center mb-2">Chinese AI Community: Open Source Heatmap 🤗</h1>
121
+ <p className="text-center text-sm mb-8">The top AI labs and model releases.</p>
122
+ <p className="text-center text-sm mb-8">Huge thanks to Caleb for the excellent original work. <a href="https://huggingface.co/spaces/cfahlgren1/model-release-heatmap" target="_blank">Link</a> to the original repo</p>
123
+ {isLoading ? (
124
+ <p className="text-center">Loading...</p>
125
+ ) : (
126
+ <div className="space-y-8 mx-10">
127
+ {Object.entries(PROVIDERS_MAP)
128
+ .sort(([keyA], [keyB]) =>
129
+ calendarData[keyB].reduce((sum, day) => sum + day.count, 0) -
130
+ calendarData[keyA].reduce((sum, day) => sum + day.count, 0)
131
+ )
132
+ .map(([providerName, { color }]) => (
133
+ <div key={providerName} className="flex flex-col">
134
+ <h2 className="text-xl font-bold mb-2">{providerName}</h2>
135
+ <div className="w-full overflow-x-auto">
136
+ <div className="inline-block mx-auto">
137
+ <ActivityCalendar
138
+ data={calendarData[providerName]}
139
+ theme={{
140
+ dark: ['#161b22', color],
141
+ light: ['#e0e0e0', color],
142
+ }}
143
+ hideTotalCount
144
+ renderBlock={(block, activity) => (
145
+ <Tooltip
146
+ title={`${activity.count} models created on ${activity.date}`}
147
+ arrow
148
+ >
149
+ {block}
150
+ </Tooltip>
151
+ )}
152
+ />
153
+ </div>
154
  </div>
155
+ </div>
156
+ ))
157
+ }
158
+ </div>
159
+ )}
160
+ </div>
161
  );
162
  }