Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -55,8 +55,28 @@ def bodyparts_plot(bodyparts, speed_csv, tmpdir):
|
|
| 55 |
|
| 56 |
plt.savefig(f'{tmpdir}/{i}.png')
|
| 57 |
|
| 58 |
-
|
| 59 |
def likelihood_plot(bodyparts, likelihood_csv, tmpdir):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
plt.figure()
|
| 61 |
for i in bodyparts:
|
| 62 |
plt.plot(likelihood_csv[i], label=i, color=cm.rainbow(int(255 * bodyparts.index(i) / len(bodyparts))))
|
|
@@ -100,6 +120,7 @@ def main(h5_file):
|
|
| 100 |
with tempfile.TemporaryDirectory(dir=".") as tmpdir:
|
| 101 |
bodyparts_plot(bodyparts, speed_csv, tmpdir)
|
| 102 |
all_plot(bodyparts, speed_csv, tmpdir)
|
|
|
|
| 103 |
likelihood_plot(bodyparts, likelihood_csv, tmpdir)
|
| 104 |
shutil.make_archive(f"{h5_file_name}", 'zip', root_dir=tmpdir)
|
| 105 |
return f"{h5_file_name}.zip"
|
|
|
|
| 55 |
|
| 56 |
plt.savefig(f'{tmpdir}/{i}.png')
|
| 57 |
|
|
|
|
| 58 |
def likelihood_plot(bodyparts, likelihood_csv, tmpdir):
|
| 59 |
+
for i in bodyparts:
|
| 60 |
+
plt.figure()
|
| 61 |
+
plt.plot(likelihood_csv[i], label=i, color=cm.rainbow(int(255 * bodyparts.index(i) / len(bodyparts))))
|
| 62 |
+
plt.legend()
|
| 63 |
+
plt.xlabel('frame')
|
| 64 |
+
plt.ylabel('likeloohood')
|
| 65 |
+
|
| 66 |
+
# 横軸の最大値を取得して設定
|
| 67 |
+
xmax = likelihood_csv.index.max()
|
| 68 |
+
plt.xlim(0, xmax)
|
| 69 |
+
plt.ylim(0, 1)
|
| 70 |
+
|
| 71 |
+
# グラフの凡例をグラフ外に表示。
|
| 72 |
+
plt.legend(bbox_to_anchor=(1.05, 1), loc='upper left', borderaxespad=0, fontsize=10)
|
| 73 |
+
|
| 74 |
+
# 凡例をすべて画像内に収める
|
| 75 |
+
plt.tight_layout()
|
| 76 |
+
|
| 77 |
+
plt.savefig(f'{tmpdir}/{i}.png')
|
| 78 |
+
|
| 79 |
+
def all_likelihood_plot(bodyparts, likelihood_csv, tmpdir):
|
| 80 |
plt.figure()
|
| 81 |
for i in bodyparts:
|
| 82 |
plt.plot(likelihood_csv[i], label=i, color=cm.rainbow(int(255 * bodyparts.index(i) / len(bodyparts))))
|
|
|
|
| 120 |
with tempfile.TemporaryDirectory(dir=".") as tmpdir:
|
| 121 |
bodyparts_plot(bodyparts, speed_csv, tmpdir)
|
| 122 |
all_plot(bodyparts, speed_csv, tmpdir)
|
| 123 |
+
all_likelihood_plot(bodyparts, likelihood_csv, tmpdir)
|
| 124 |
likelihood_plot(bodyparts, likelihood_csv, tmpdir)
|
| 125 |
shutil.make_archive(f"{h5_file_name}", 'zip', root_dir=tmpdir)
|
| 126 |
return f"{h5_file_name}.zip"
|