Spaces:
Build error
Build error
Ubuntu
commited on
Commit
·
d24bd0f
1
Parent(s):
92c0827
- .ipynb_checkpoints/app-checkpoint.py +26 -24
- app.py +26 -24
.ipynb_checkpoints/app-checkpoint.py
CHANGED
|
@@ -5,36 +5,38 @@ from encoded_video import EncodedVideo, write_video
|
|
| 5 |
import torch
|
| 6 |
import numpy as np
|
| 7 |
|
| 8 |
-
def video_identity(video,user_name,class_name):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
|
| 11 |
-
capture = cv2.VideoCapture(video)
|
| 12 |
-
user_d=str(user_name)
|
| 13 |
-
class_d=str(user_name)+'/'+str(class_name)
|
| 14 |
-
if os.path.exists(class_d):
|
| 15 |
-
here='something'
|
| 16 |
-
if not os.path.exists(user_d):
|
| 17 |
-
os.makedirs(user_d)
|
| 18 |
-
if not os.path.exists(class_d):
|
| 19 |
-
os.makedirs(class_d)
|
| 20 |
-
frameNr = 0
|
| 21 |
-
while (True):
|
| 22 |
-
|
| 23 |
-
success, frame = capture.read()
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
demo = gr.Interface(video_identity,
|
| 37 |
inputs=[gr.Video(source='upload'),
|
|
|
|
|
|
|
| 38 |
gr.Text(),
|
| 39 |
gr.Text()],
|
| 40 |
outputs=[gr.Image(),
|
|
|
|
| 5 |
import torch
|
| 6 |
import numpy as np
|
| 7 |
|
| 8 |
+
def video_identity(video,user_name,class_name,trainortest,ready):
|
| 9 |
+
if ready=='yes':
|
| 10 |
+
return user_name
|
| 11 |
+
else:
|
| 12 |
+
capture = cv2.VideoCapture(video)
|
| 13 |
+
|
| 14 |
+
user_d=str(trainortest)+str(user_name)
|
| 15 |
+
class_d=str(trainortest)+str(user_name)+'/'+str(class_name)
|
| 16 |
+
if not os.path.exists(user_d):
|
| 17 |
+
os.makedirs(user_d)
|
| 18 |
+
if not os.path.exists(class_d):
|
| 19 |
+
os.makedirs(class_d)
|
| 20 |
+
frameNr = 0
|
| 21 |
+
while (True):
|
| 22 |
|
| 23 |
+
success, frame = capture.read()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
+
if success:
|
| 26 |
+
cv2.imwrite(f'{class_d}/frame_{frameNr}.jpg', frame)
|
| 27 |
|
| 28 |
+
else:
|
| 29 |
+
break
|
| 30 |
|
| 31 |
+
frameNr = frameNr+10
|
| 32 |
+
|
| 33 |
+
img=cv2.imread(class_d+'/frame_0.jpg')
|
| 34 |
+
|
| 35 |
+
return img, class_d
|
| 36 |
demo = gr.Interface(video_identity,
|
| 37 |
inputs=[gr.Video(source='upload'),
|
| 38 |
+
gr.Text(),
|
| 39 |
+
gr.Text(),
|
| 40 |
gr.Text(),
|
| 41 |
gr.Text()],
|
| 42 |
outputs=[gr.Image(),
|
app.py
CHANGED
|
@@ -5,36 +5,38 @@ from encoded_video import EncodedVideo, write_video
|
|
| 5 |
import torch
|
| 6 |
import numpy as np
|
| 7 |
|
| 8 |
-
def video_identity(video,user_name,class_name):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
|
| 11 |
-
capture = cv2.VideoCapture(video)
|
| 12 |
-
user_d=str(user_name)
|
| 13 |
-
class_d=str(user_name)+'/'+str(class_name)
|
| 14 |
-
if os.path.exists(class_d):
|
| 15 |
-
here='something'
|
| 16 |
-
if not os.path.exists(user_d):
|
| 17 |
-
os.makedirs(user_d)
|
| 18 |
-
if not os.path.exists(class_d):
|
| 19 |
-
os.makedirs(class_d)
|
| 20 |
-
frameNr = 0
|
| 21 |
-
while (True):
|
| 22 |
-
|
| 23 |
-
success, frame = capture.read()
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
demo = gr.Interface(video_identity,
|
| 37 |
inputs=[gr.Video(source='upload'),
|
|
|
|
|
|
|
| 38 |
gr.Text(),
|
| 39 |
gr.Text()],
|
| 40 |
outputs=[gr.Image(),
|
|
|
|
| 5 |
import torch
|
| 6 |
import numpy as np
|
| 7 |
|
| 8 |
+
def video_identity(video,user_name,class_name,trainortest,ready):
|
| 9 |
+
if ready=='yes':
|
| 10 |
+
return user_name
|
| 11 |
+
else:
|
| 12 |
+
capture = cv2.VideoCapture(video)
|
| 13 |
+
|
| 14 |
+
user_d=str(trainortest)+str(user_name)
|
| 15 |
+
class_d=str(trainortest)+str(user_name)+'/'+str(class_name)
|
| 16 |
+
if not os.path.exists(user_d):
|
| 17 |
+
os.makedirs(user_d)
|
| 18 |
+
if not os.path.exists(class_d):
|
| 19 |
+
os.makedirs(class_d)
|
| 20 |
+
frameNr = 0
|
| 21 |
+
while (True):
|
| 22 |
|
| 23 |
+
success, frame = capture.read()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
+
if success:
|
| 26 |
+
cv2.imwrite(f'{class_d}/frame_{frameNr}.jpg', frame)
|
| 27 |
|
| 28 |
+
else:
|
| 29 |
+
break
|
| 30 |
|
| 31 |
+
frameNr = frameNr+10
|
| 32 |
+
|
| 33 |
+
img=cv2.imread(class_d+'/frame_0.jpg')
|
| 34 |
+
|
| 35 |
+
return img, class_d
|
| 36 |
demo = gr.Interface(video_identity,
|
| 37 |
inputs=[gr.Video(source='upload'),
|
| 38 |
+
gr.Text(),
|
| 39 |
+
gr.Text(),
|
| 40 |
gr.Text(),
|
| 41 |
gr.Text()],
|
| 42 |
outputs=[gr.Image(),
|