Update vit_model_test.py
Browse files- vit_model_test.py +17 -9
vit_model_test.py
CHANGED
@@ -13,10 +13,15 @@ import seaborn as sns
|
|
13 |
# 驻讜谞拽爪讬讛 诇讛讞讝专转 HTML 砖诇 住专讟讜谉
|
14 |
def display_video(video_url):
|
15 |
return f'''
|
16 |
-
<
|
17 |
-
<
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
20 |
'''
|
21 |
|
22 |
def shuffle_and_split_data(dataframe, test_size=0.2, random_state=59):
|
@@ -50,11 +55,6 @@ if __name__ == "__main__":
|
|
50 |
# Load the trained model
|
51 |
model.load_state_dict(torch.load('trained_model.pth'))
|
52 |
|
53 |
-
# Evaluate the model
|
54 |
-
model.eval()
|
55 |
-
true_labels = []
|
56 |
-
predicted_labels = []
|
57 |
-
|
58 |
# 拽讬砖讜专 诇住专讟讜谉
|
59 |
video_url = 'https://rr5---sn-33uxaxjvh-aixe.googlevideo.com/videoplayback?expire=1727025979&ei=2_7vZrzMAuGdp-oPuaTo-QI&ip=39.62.1.120&id=o-AJ04-wA4jR6nhlg7B-yNUOXEwR7yoNlJetni5NaAoWRl&itag=134&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278&source=youtube&requiressl=yes&xpc=EgVo2aDSNQ%3D%3D&mh=9z&mm=31%2C29&mn=sn-33uxaxjvh-aixe%2Csn-hju7enll&ms=au%2Crdu&mv=m&mvi=5&pl=24&initcwndbps=306250&bui=AXLXGFS9xlNb5y-figGb1FTTN1Ma8zVRiN7RtpZjebiJgICl7QFK5ab9UDZVXvwn2GwOYj4m4rXuQlYc&spc=54MbxY0qT7L8eXI7eMdKq6id860EyvqxATj5F0MLSzmNFdC1mD-XNkZUkcL1EWQ&vprv=1&svpuc=1&mime=video%2Fmp4&ns=qN73Wubd4RAEtRCu3S2dItYQ&rqh=1&gir=yes&clen=242900&dur=5.000&lmt=1727003020660351&mt=1727004294&fvip=2&keepalive=yes&fexp=51299152&c=WEB&sefc=1&txp=630A224&n=Y84SAecGmAZzwg&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cxpc%2Cbui%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Cns%2Crqh%2Cgir%2Cclen%2Cdur%2Clmt&sig=AJfQdSswRAIgGjjE8lnq2bVWML91M2fA0A3qtumgsH-bASH-qjraIRwCIBh9oYh7GnjGwTNescuIZ1qgv4PBj0WOzJJbveuTUOb8&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=ABPmVW0wRQIgCwVg3G31n-JXtH0t66MDGpnLR8s-mRwiTjMQP9TeTawCIQC2zaC1iwicMoTjn6ha46-W1UZrW6Rv9D8HP5I96C1hfg%3D%3D&extt=mp4' # 讛讞诇讬驻讬 讻讗谉 注诐 讛-URL 砖诇 讛住专讟讜谉 砖诇讱
|
60 |
video_html = display_video(video_url)
|
@@ -62,6 +62,14 @@ if __name__ == "__main__":
|
|
62 |
# 讛专讗讬 讗转 讛住专讟讜谉 诇驻谞讬 讛讞讬讝讜讬
|
63 |
print(video_html) # 讝讛 讗诪讜专 诇讛爪讬讙 讗转 讛-HTML 讘讚砖讘讜专讚 砖诇讱
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
with torch.no_grad():
|
66 |
for images, labels in test_loader:
|
67 |
images, labels = images.to(device), labels.to(device)
|
|
|
13 |
# 驻讜谞拽爪讬讛 诇讛讞讝专转 HTML 砖诇 住专讟讜谉
|
14 |
def display_video(video_url):
|
15 |
return f'''
|
16 |
+
<div id="video-container" style="display: none;">
|
17 |
+
<video width="640" height="480" controls autoplay>
|
18 |
+
<source src="{video_url}" type="video/mp4">
|
19 |
+
Your browser does not support the video tag.
|
20 |
+
</video>
|
21 |
+
</div>
|
22 |
+
<script>
|
23 |
+
document.getElementById('video-container').style.display = 'block';
|
24 |
+
</script>
|
25 |
'''
|
26 |
|
27 |
def shuffle_and_split_data(dataframe, test_size=0.2, random_state=59):
|
|
|
55 |
# Load the trained model
|
56 |
model.load_state_dict(torch.load('trained_model.pth'))
|
57 |
|
|
|
|
|
|
|
|
|
|
|
58 |
# 拽讬砖讜专 诇住专讟讜谉
|
59 |
video_url = 'https://rr5---sn-33uxaxjvh-aixe.googlevideo.com/videoplayback?expire=1727025979&ei=2_7vZrzMAuGdp-oPuaTo-QI&ip=39.62.1.120&id=o-AJ04-wA4jR6nhlg7B-yNUOXEwR7yoNlJetni5NaAoWRl&itag=134&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278&source=youtube&requiressl=yes&xpc=EgVo2aDSNQ%3D%3D&mh=9z&mm=31%2C29&mn=sn-33uxaxjvh-aixe%2Csn-hju7enll&ms=au%2Crdu&mv=m&mvi=5&pl=24&initcwndbps=306250&bui=AXLXGFS9xlNb5y-figGb1FTTN1Ma8zVRiN7RtpZjebiJgICl7QFK5ab9UDZVXvwn2GwOYj4m4rXuQlYc&spc=54MbxY0qT7L8eXI7eMdKq6id860EyvqxATj5F0MLSzmNFdC1mD-XNkZUkcL1EWQ&vprv=1&svpuc=1&mime=video%2Fmp4&ns=qN73Wubd4RAEtRCu3S2dItYQ&rqh=1&gir=yes&clen=242900&dur=5.000&lmt=1727003020660351&mt=1727004294&fvip=2&keepalive=yes&fexp=51299152&c=WEB&sefc=1&txp=630A224&n=Y84SAecGmAZzwg&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cxpc%2Cbui%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Cns%2Crqh%2Cgir%2Cclen%2Cdur%2Clmt&sig=AJfQdSswRAIgGjjE8lnq2bVWML91M2fA0A3qtumgsH-bASH-qjraIRwCIBh9oYh7GnjGwTNescuIZ1qgv4PBj0WOzJJbveuTUOb8&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=ABPmVW0wRQIgCwVg3G31n-JXtH0t66MDGpnLR8s-mRwiTjMQP9TeTawCIQC2zaC1iwicMoTjn6ha46-W1UZrW6Rv9D8HP5I96C1hfg%3D%3D&extt=mp4' # 讛讞诇讬驻讬 讻讗谉 注诐 讛-URL 砖诇 讛住专讟讜谉 砖诇讱
|
60 |
video_html = display_video(video_url)
|
|
|
62 |
# 讛专讗讬 讗转 讛住专讟讜谉 诇驻谞讬 讛讞讬讝讜讬
|
63 |
print(video_html) # 讝讛 讗诪讜专 诇讛爪讬讙 讗转 讛-HTML 讘讚砖讘讜专讚 砖诇讱
|
64 |
|
65 |
+
# Evaluate the model
|
66 |
+
model.eval()
|
67 |
+
true_labels = []
|
68 |
+
predicted_labels = []
|
69 |
+
|
70 |
+
# 讛专讗讛 讗转 讛住专讟讜谉 讘注转 讞讬讝讜讬
|
71 |
+
print(video_html) # 讛爪讙 讗转 讛-HTML 砖诇 讛住专讟讜谉
|
72 |
+
|
73 |
with torch.no_grad():
|
74 |
for images, labels in test_loader:
|
75 |
images, labels = images.to(device), labels.to(device)
|