RyanPham19092002 commited on
Commit
b4297d6
1 Parent(s): 43d0d80

Add application file

Browse files
00000.json ADDED
@@ -0,0 +1 @@
 
 
1
+ [{"Class": "person", "BoundingBox": [12.102564811706543, 8.40479850769043, 331.9989013671875, 504.0], "Confidence": 0.7372510433197021}]
Client_Server_isods.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"installed":{"client_id":"993373330768-nlm1aii22j4sek1a5ag5e2rdiagfiva9.apps.googleusercontent.com","project_id":"clever-stone-394203","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"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","redirect_uris":["http://localhost"]}}
Google.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pickle
2
+ import os
3
+ from google_auth_oauthlib.flow import Flow, InstalledAppFlow
4
+ from googleapiclient.discovery import build
5
+ from googleapiclient.http import MediaFileUpload, MediaIoBaseDownload
6
+ from google.auth.transport.requests import Request
7
+
8
+
9
+ def Create_Service(client_secret_file, api_name, api_version, *scopes):
10
+ print(client_secret_file, api_name, api_version, scopes, sep='-')
11
+ CLIENT_SECRET_FILE = client_secret_file
12
+ API_SERVICE_NAME = api_name
13
+ API_VERSION = api_version
14
+ SCOPES = [scope for scope in scopes[0]]
15
+ print(SCOPES)
16
+
17
+ cred = None
18
+
19
+ pickle_file = f'token_{API_SERVICE_NAME}_{API_VERSION}.pickle'
20
+ # print(pickle_file)
21
+
22
+ if os.path.exists(pickle_file):
23
+ with open(pickle_file, 'rb') as token:
24
+ cred = pickle.load(token)
25
+
26
+ if not cred or not cred.valid:
27
+ if cred and cred.expired and cred.refresh_token:
28
+ cred.refresh(Request())
29
+ else:
30
+ flow = InstalledAppFlow.from_client_secrets_file(CLIENT_SECRET_FILE, SCOPES)
31
+ cred = flow.run_local_server()
32
+
33
+ with open(pickle_file, 'wb') as token:
34
+ pickle.dump(cred, token)
35
+
36
+ try:
37
+ service = build(API_SERVICE_NAME, API_VERSION, credentials=cred)
38
+ print(API_SERVICE_NAME, 'service created successfully')
39
+ return service
40
+ except Exception as e:
41
+ print('Unable to connect.')
42
+ print(e)
43
+ return None
44
+
45
+ def convert_to_RFC_datetime(year=1900, month=1, day=1, hour=0, minute=0):
46
+ dt = datetime.datetime(year, month, day, hour, minute, 0).isoformat() + 'Z'
47
+ return dt
Load_image_Client.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"installed":{"client_id":"709256034265-gpo1qcstq1dnko3rbt7md081g38lfcsb.apps.googleusercontent.com","project_id":"test2drive-394218","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"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","redirect_uris":["http://localhost"]}}
__pycache__/Google.cpython-311.pyc ADDED
Binary file (3.13 kB). View file
 
__pycache__/Google.cpython-37.pyc ADDED
Binary file (1.69 kB). View file
 
__pycache__/Google.cpython-38.pyc ADDED
Binary file (1.72 kB). View file
 
__pycache__/image_ID.cpython-38.pyc ADDED
Binary file (3.08 kB). View file
 
__pycache__/load_data_from_client.cpython-38.pyc ADDED
Binary file (3.31 kB). View file
 
demo.py ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import cv2
3
+ import sys
4
+ import time
5
+ import math
6
+ import random
7
+ import numpy as np
8
+ import socket
9
+ import pickle
10
+ import torch
11
+ from Google import Create_Service
12
+ from googleapiclient.http import MediaFileUpload
13
+ from googleapiclient.http import MediaIoBaseDownload
14
+ CLIENT_SECRET_FILE="D:/cuoc_thi/object-detection/Client_Server_isods.json"
15
+ API_NAME = "drive"
16
+ API_VERSION = "v3"
17
+ SCOPES=["https://www.googleapis.com/auth/drive", 'https://www.googleapis.com/auth/drive.file']
18
+ service = Create_Service(CLIENT_SECRET_FILE, API_NAME, API_VERSION, SCOPES)
19
+ folder_id_input = '1r4RDsWv0xc_XV6IRrgkfQEcJKC8i3Xy3'
20
+ folder_id_output = '1IcWWr2s6pWS-QhgfBzFbd2UCR6jAZtbc'
21
+ #model = torch.hub.load('D:/cuoc_thi/Advanced/yolov5s.pt', pretrained=True)
22
+
23
+ def load_image (file_image_name):
24
+ file_names = [file_image_name]
25
+ mime_types = ['image/jpeg']
26
+ for file_name, mime_type in zip(file_names,mime_types):
27
+ file_metadata = {
28
+ 'name': file_name,
29
+ 'parents' : [folder_id_output]
30
+ }
31
+
32
+ media = MediaFileUpload('D:/cuoc_thi/object-detection/{0}'.format(file_name), mimetype = mime_type)
33
+
34
+ service.files().create(
35
+ body=file_metadata,
36
+ media_body =media,
37
+ fields='id'
38
+ ).execute()
39
+
40
+ def load_json (file_json_name):
41
+ file_names = [file_json_name]
42
+ mime_types = ['file_json_name']
43
+ for file_name, mime_type in zip(file_names,mime_types):
44
+ file_metadata = {
45
+ 'name': file_name,
46
+ 'parents' : [folder_id_output]
47
+ }
48
+
49
+ media = MediaFileUpload('D:/cuoc_thi/object-detection/{0}'.format(file_name), mimetype = mime_type)
50
+
51
+ service.files().create(
52
+ body=file_metadata,
53
+ media_body =media,
54
+ fields='id'
55
+ ).execute()
56
+
57
+ cnt = 0
58
+ cap = cv2.VideoCapture(0)
59
+ while(cap.isOpened()):
60
+ ret, frame = cap.read()
61
+
62
+ cv2.imshow('frame',frame)
63
+ if cv2.waitKey(1) & 0xFF == ord('q'):
64
+ break
65
+
66
+ name_image ='{:05d}.jpg'.format(cnt)
67
+ print(name_image)
68
+ cv2.imwrite(name_image, frame) # save figures if necessay
69
+ load_image(name_image)
70
+ os.remove(name_image)
71
+ cnt+=1
72
+ if cnt == 100:
73
+ break
74
+
75
+ cap.release()
76
+ cv2.destroyAllWindows()
download.jpg ADDED
image_ID.py ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import cv2
3
+ import sys
4
+ import time
5
+ import math
6
+ import random
7
+ import numpy as np
8
+ import socket
9
+ import pickle
10
+ import io
11
+ import torch
12
+ import json
13
+ from google.oauth2.credentials import Credentials
14
+ from googleapiclient.discovery import build
15
+ from googleapiclient.errors import HttpError
16
+ from Google import Create_Service
17
+ from googleapiclient.http import MediaFileUpload
18
+ from googleapiclient.http import MediaIoBaseDownload
19
+ from load_data_from_client import load_image, run_webcam
20
+
21
+ def get_image_from_drive(frame_id):
22
+ # Lấy dữ liệu ảnh từ Google Drive
23
+ response = Server_drive.files().get_media(fileId=frame_id).execute()
24
+
25
+ # Chuyển đổi dữ liệu ảnh thành mảng numpy
26
+ image_bytes = io.BytesIO(response)
27
+ image_array = np.asarray(bytearray(image_bytes.read()), dtype=np.uint8)
28
+ image = cv2.imdecode(image_array, cv2.IMREAD_COLOR)
29
+ return image
30
+ def load_json_file(file_json_name, folder_id_output, Server_drive):
31
+ file_metadata = {'name': file_json_name, 'parents': [folder_id_output]}
32
+ media = MediaFileUpload('D:/cuoc_thi/object-detection/{0}'.format(file_json_name), mimetype = 'application/json')
33
+
34
+ # Tải lên tệp tin vào thư mục chỉ định
35
+ file = Server_drive.files().create(
36
+ body=file_metadata,
37
+ media_body=media,
38
+ fields='id'
39
+ ).execute()
40
+
41
+
42
+ # Xác thực tài khoản Google Drive thứ nhất
43
+ Server = Credentials.from_authorized_user_file("D:/cuoc_thi/object-detection/token_Server.json", ['https://www.googleapis.com/auth/drive', 'https://www.googleapis.com/auth/drive.file'])
44
+ Server_drive = build('drive', 'v3', credentials=Server)
45
+ about_server = Server_drive.about().get(fields='user').execute()
46
+ server_user = about_server['user']['emailAddress']
47
+ print('Tài khoản Google Drive Server hiện đang được sử dụng là:', server_user)
48
+ folder_id_output = '1IcWWr2s6pWS-QhgfBzFbd2UCR6jAZtbc'
49
+
50
+ #model
51
+ model = torch.hub.load('ultralytics/yolov5','yolov5s', pretrained=True)
52
+
53
+
54
+ #tìm ID folder
55
+ query_folder = "mimeType='application/vnd.google-apps.folder' and sharedWithMe=true and trashed=false"
56
+ results_folder = Server_drive.files().list(q=query_folder, fields="nextPageToken, files(id, name)").execute()
57
+ items_folder = results_folder.get('files', [])
58
+ folder_name = "Input"
59
+ folder_id = None
60
+ for item in items_folder:
61
+ if item['name'] == folder_name:
62
+ folder_id = item['id']
63
+ #print(folder_id)
64
+ break
65
+
66
+ #Tìm ID ảnh
67
+ cnt = 0
68
+ query_img = "mimeType='image/jpeg' and trashed=false and parents in '{}'".format(folder_id)
69
+ results_img = Server_drive.files().list(q=query_img, fields="nextPageToken, files(id)").execute()
70
+ items_img = results_img.get('files', [])
71
+ for item in items_img:
72
+ print(item['id'],item)
73
+ frame = get_image_from_drive(item['id'])
74
+ objects = []
75
+ prediction = model(frame)
76
+ for det in prediction.xyxy[0]:
77
+ class_id = int(det[5])
78
+ class_name = model.names[class_id]
79
+ confidence = float(det[4])
80
+ bbox = det[:4].tolist()
81
+ if(confidence >= 0.5):
82
+ # Save the results to the list
83
+ objects.append({
84
+ 'Class': class_name,
85
+ 'BoundingBox': bbox,
86
+ 'Confidence': confidence
87
+ })
88
+ name_json ='{:05d}.json'.format(cnt)
89
+ with open(name_json , 'w') as f:
90
+ json.dump(objects, f)
91
+ load_json_file(name_json, folder_id_output, Server_drive)
92
+ cnt += 1
93
+ print(cnt)
94
+ #os.remove(name_json)
95
+
96
+
link_2_drive.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import cv2
3
+ import sys
4
+ import time
5
+ import math
6
+ import random
7
+ import numpy as np
8
+ import socket
9
+ import pickle
10
+ import io
11
+ import torch
12
+ import json
13
+ from google.oauth2.credentials import Credentials
14
+ from googleapiclient.discovery import build
15
+ from googleapiclient.errors import HttpError
16
+ from Google import Create_Service
17
+ from googleapiclient.http import MediaFileUpload
18
+ from googleapiclient.http import MediaIoBaseDownload
19
+ from load_data_from_client import load_image, run_webcam
20
+ # Xác thực tài khoản Google Drive thứ nhất
21
+ Server = Credentials.from_authorized_user_file("D:/cuoc_thi/object-detection/token_Server.json", ['https://www.googleapis.com/auth/drive', 'https://www.googleapis.com/auth/drive.file'])
22
+ Server_drive = build('drive', 'v3', credentials=Server)
23
+ folder_id_output = '1IcWWr2s6pWS-QhgfBzFbd2UCR6jAZtbc'
24
+ about_server = Server_drive.about().get(fields='user').execute()
25
+ server_user = about_server['user']['emailAddress']
26
+ print('Tài khoản Google Drive Server hiện đang được sử dụng là:', server_user)
27
+
28
+
29
+ # Xác thực tài khoản Google Drive thứ hai
30
+ Client = Credentials.from_authorized_user_file("D:/cuoc_thi/object-detection/token_Client.json", ['https://www.googleapis.com/auth/drive', 'https://www.googleapis.com/auth/drive.file'])
31
+ Client_drive = build('drive', 'v3', credentials=Client)
32
+ about_client = Client_drive.about().get(fields='user').execute()
33
+ client_user = about_client['user']['emailAddress']
34
+ print('Tài khoản Google Drive Client hiện đang được sử dụng là:', client_user)
35
+
36
+
37
+ # Tạo một thư mục mới trên tài khoản thứ nhất
38
+ folder_metadata = {'name': 'Input', 'mimeType': 'application/vnd.google-apps.folder'}
39
+ folder = Client_drive.files().create(body=folder_metadata, fields='id').execute()
40
+ folder_id_input = folder.get('id')
41
+ # Chia sẻ thư mục với tài khoản thứ hai
42
+ permission = {'type': 'user', 'role': 'writer', 'emailAddress': server_user, 'Domain': 'global'}
43
+ Client_drive.permissions().create(fileId=folder_id_input, body=permission).execute()
44
+
45
+ # Kiểm tra xem tài khoản thứ hai có thể truy cập vào thư mục mới không
46
+ try:
47
+ Server_drive.files().get(fileId=folder_id_input).execute()
48
+ print('Liên kết tài khoản thành công')
49
+ except HttpError as error:
50
+ print('Liên kết tài khoản không thành công:', error)
51
+
52
+
53
+ #//-----------------------------------------------------------------------------------------------------------------------------
54
+ run_webcam(folder_id_input, folder_id_output, Client_drive, Server_drive)
load_data_from_client.py ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import cv2
3
+ import sys
4
+ import time
5
+ import math
6
+ import random
7
+ import numpy as np
8
+ import socket
9
+ import pickle
10
+ import io
11
+ import torch
12
+ import json
13
+ import time
14
+ from google.oauth2.credentials import Credentials
15
+ from googleapiclient.discovery import build
16
+ from googleapiclient.errors import HttpError
17
+ from Google import Create_Service
18
+ from googleapiclient.http import MediaFileUpload
19
+ from googleapiclient.http import MediaIoBaseDownload
20
+
21
+
22
+ Server = Credentials.from_authorized_user_file("D:/cuoc_thi/object-detection/token_Server.json", ['https://www.googleapis.com/auth/drive', 'https://www.googleapis.com/auth/drive.file'])
23
+ Server_drive = build('drive', 'v3', credentials=Server)
24
+ Client = Credentials.from_authorized_user_file("D:/cuoc_thi/object-detection/token_Client.json", ['https://www.googleapis.com/auth/drive', 'https://www.googleapis.com/auth/drive.file'])
25
+ Client_drive = build('drive', 'v3', credentials=Client)
26
+ folder_id_output = '1IcWWr2s6pWS-QhgfBzFbd2UCR6jAZtbc'
27
+
28
+ model = torch.hub.load('ultralytics/yolov5','yolov5s', pretrained=True)
29
+
30
+
31
+
32
+ def get_image_from_drive(frame_id):
33
+ # Lấy dữ liệu ảnh từ Google Drive
34
+ response = Server_drive.files().get_media(fileId=frame_id).execute()
35
+
36
+ # Chuyển đổi dữ liệu ảnh thành mảng numpy
37
+ image_bytes = io.BytesIO(response)
38
+ image_array = np.asarray(bytearray(image_bytes.read()), dtype=np.uint8)
39
+ image = cv2.imdecode(image_array, cv2.IMREAD_COLOR)
40
+ return image
41
+
42
+ def load_json_file(file_json_name, folder_id_output, Server_drive):
43
+ file_metadata = {'name': file_json_name, 'parents': [folder_id_output]}
44
+ media = MediaFileUpload('D:/cuoc_thi/object-detection/{0}'.format(file_json_name), mimetype = 'application/json')
45
+
46
+ def load_image (file_image_name, folder_id_input, Client_drive):
47
+ file_metadata = {'name': file_image_name, 'parents': [folder_id_input]}
48
+ media = MediaFileUpload('D:/cuoc_thi/object-detection/{0}'.format(file_image_name), mimetype = 'image/jpeg')
49
+
50
+ # Tải lên tệp tin vào thư mục chỉ định
51
+ file = Client_drive.files().create(
52
+ body=file_metadata,
53
+ media_body=media,
54
+ fields='id'
55
+ ).execute()
56
+ def run_webcam(folder_id_input, folder_id_output, Client_drive, Server_drive):
57
+ cnt = 0
58
+ cap = cv2.VideoCapture(0)
59
+ while(cap.isOpened()):
60
+ ret, frame = cap.read()
61
+
62
+ cv2.imshow('frame',frame)
63
+ if cv2.waitKey(1) & 0xFF == ord('q'):
64
+ break
65
+
66
+ name_image ='{:05d}.jpg'.format(cnt)
67
+ print(name_image)
68
+ cv2.imwrite(name_image, frame) # save figures if necessay
69
+ load_image(name_image, folder_id_input, Client_drive)
70
+ os.remove(name_image)
71
+ #cnt+=1
72
+ query_img = "mimeType='image/jpeg' and trashed=false and parents in '{}'".format(folder_id_input)
73
+ results_img = Server_drive.files().list(q=query_img, fields="nextPageToken, files(id)").execute()
74
+ items_img = results_img.get('files', [])
75
+ for item in items_img:
76
+ print(item['id'],item)
77
+ frame = get_image_from_drive(item['id'])
78
+ objects = []
79
+ prediction = model(frame)
80
+ for det in prediction.xyxy[0]:
81
+ class_id = int(det[5])
82
+ class_name = model.names[class_id]
83
+ confidence = float(det[4])
84
+ bbox = det[:4].tolist()
85
+ if(confidence >= 0.5):
86
+ # Save the results to the list
87
+ objects.append({
88
+ 'Class': class_name,
89
+ 'BoundingBox': bbox,
90
+ 'Confidence': confidence
91
+ })
92
+ name_json ='{:05d}.json'.format(cnt)
93
+ with open(name_json , 'w') as f:
94
+ json.dump(objects, f)
95
+ load_json_file(name_json, folder_id_output, Server_drive)
96
+ cnt += 1
97
+ print(cnt)
98
+ #os.remove(name_json)
99
+
100
+
101
+
102
+ if cnt == 10:
103
+ break
104
+
105
+ cap.release()
106
+ cv2.destroyAllWindows()
model.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import cv2
3
+ import sys
4
+ import time
5
+ import math
6
+ import random
7
+ import numpy as np
8
+ import socket
9
+ import pickle
10
+ import torch
11
+ import json
12
+ from google.oauth2.credentials import Credentials
13
+ from googleapiclient.discovery import build
14
+ from googleapiclient.errors import HttpError
15
+ from Google import Create_Service
16
+ from googleapiclient.http import MediaFileUpload
17
+ from googleapiclient.http import MediaIoBaseDownload
18
+
19
+ model = torch.hub.load('ultralytics/yolov5','yolov5s', pretrained=True)
20
+ cnt = 0
21
+ def turn_img_into_fileJSON(frame):
22
+ global cnt
23
+
24
+ print(cnt)
25
+ objects = []
26
+ prediction = model(frame)
27
+ for det in prediction.xyxy[0]:
28
+ class_id = int(det[5])
29
+ class_name = model.names[class_id]
30
+ confidence = float(det[4])
31
+ bbox = det[:4].tolist()
32
+ if(confidence >= 0.5):
33
+ # Save the results to the list
34
+ objects.append({
35
+ 'Class': class_name,
36
+ 'BoundingBox': bbox,
37
+ 'Confidence': confidence
38
+ })
39
+ with open('{:05d}.json'.format(cnt) , 'w') as f:
40
+ json.dump(objects, f)
41
+ cnt += 1
42
+
43
+ turn_img_into_fileJSON("D:/cuoc_thi/object-detection/download.jpg")
44
+ turn_img_into_fileJSON("D:/cuoc_thi/object-detection/download.jpg")
quickstart.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import print_function
2
+
3
+ import os.path
4
+
5
+ from google.auth.transport.requests import Request
6
+ from google.oauth2.credentials import Credentials
7
+ from google_auth_oauthlib.flow import InstalledAppFlow
8
+ from googleapiclient.discovery import build
9
+ from googleapiclient.errors import HttpError
10
+
11
+ # If modifying these scopes, delete the file token.json.
12
+ SCOPES = ['https://www.googleapis.com/auth/drive.metadata.readonly','https://www.googleapis.com/auth/drive', 'https://www.googleapis.com/auth/drive.file']
13
+
14
+
15
+ def main():
16
+ """Shows basic usage of the Drive v3 API.
17
+ Prints the names and ids of the first 10 files the user has access to.
18
+ """
19
+ creds = None
20
+ # The file token.json stores the user's access and refresh tokens, and is
21
+ # created automatically when the authorization flow completes for the first
22
+ # time.
23
+ if os.path.exists('token_Server.json'):
24
+ creds = Credentials.from_authorized_user_file('token_Server.json', SCOPES)
25
+ # If there are no (valid) credentials available, let the user log in.
26
+ if not creds or not creds.valid:
27
+ if creds and creds.expired and creds.refresh_token:
28
+ creds.refresh(Request())
29
+ else:
30
+ flow = InstalledAppFlow.from_client_secrets_file(
31
+ 'D:/cuoc_thi/object-detection/Client_Server_isods.json', SCOPES)
32
+ creds = flow.run_local_server(port=0)
33
+ # Save the credentials for the next run
34
+ with open('token_Server.json', 'w') as token:
35
+ token.write(creds.to_json())
36
+
37
+ try:
38
+ service = build('drive', 'v3', credentials=creds)
39
+
40
+ # Call the Drive v3 API
41
+ results = service.files().list(
42
+ pageSize=10, fields="nextPageToken, files(id, name)").execute()
43
+ items = results.get('files', [])
44
+
45
+ if not items:
46
+ print('No files found.')
47
+ return
48
+ print('Files:')
49
+ for item in items:
50
+ print(u'{0} ({1})'.format(item['name'], item['id']))
51
+ except HttpError as error:
52
+ # TODO(developer) - Handle errors from drive API.
53
+ print(f'An error occurred: {error}')
54
+
55
+
56
+ if __name__ == '__main__':
57
+ main()
requirements.txt ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file may be used to create an environment using:
2
+ # $ conda create --name <env> --file <this file>
3
+ # platform: win-64
4
+ aiofiles=23.1.0=pyhd8ed1ab_1
5
+ aiohttp=3.8.5=py38h91455d4_0
6
+ aiosignal=1.3.1=pyhd8ed1ab_0
7
+ altair=5.0.1=pyhd8ed1ab_1
8
+ annotated-types=0.5.0=pyhd8ed1ab_0
9
+ anyio=3.7.1=pyhd8ed1ab_0
10
+ asttokens=2.2.1=pyhd8ed1ab_0
11
+ async-timeout=4.0.2=pyhd8ed1ab_0
12
+ attrs=23.1.0=pyh71513ae_1
13
+ backcall=0.2.0=pyh9f0ad1d_0
14
+ backports=1.0=pyhd8ed1ab_3
15
+ backports.functools_lru_cache=1.6.5=pyhd8ed1ab_0
16
+ brotli-python=1.0.9=py38hd3f51b4_9
17
+ bzip2=1.0.8=h8ffe710_4
18
+ ca-certificates=2023.7.22=h56e8100_0
19
+ cachetools=5.3.1=pypi_0
20
+ certifi=2023.7.22=pypi_0
21
+ cffi=1.15.1=pypi_0
22
+ charset-normalizer=3.2.0=pyhd8ed1ab_0
23
+ click=8.1.6=win_pyh7428d3b_0
24
+ colorama=0.4.6=pyhd8ed1ab_0
25
+ cryptography=41.0.2=pypi_0
26
+ cycler=0.11.0=pyhd8ed1ab_0
27
+ decorator=5.1.1=pyhd8ed1ab_0
28
+ eigen=3.4.0=h91493d7_0
29
+ exceptiongroup=1.1.2=pyhd8ed1ab_0
30
+ executing=1.2.0=pyhd8ed1ab_0
31
+ fastapi=0.100.1=pyhd8ed1ab_0
32
+ ffmpeg=4.2.3=ha925a31_0
33
+ ffmpy=0.3.0=pyhb6f538c_0
34
+ filelock=3.12.2=pyhd8ed1ab_0
35
+ freetype=2.12.1=h546665d_1
36
+ frozenlist=1.4.0=py38h91455d4_0
37
+ fsspec=2023.6.0=pyh1a96a4e_0
38
+ gettext=0.21.1=h5728263_0
39
+ gitdb=4.0.10=pypi_0
40
+ gitpython=3.1.32=pypi_0
41
+ glib=2.76.4=h12be248_0
42
+ glib-tools=2.76.4=h12be248_0
43
+ google-api-core=2.11.1=pypi_0
44
+ google-api-python-client=2.95.0=pypi_0
45
+ google-auth=2.22.0=pypi_0
46
+ google-auth-httplib2=0.1.0=pypi_0
47
+ google-auth-oauthlib=1.0.0=pypi_0
48
+ googleapis-common-protos=1.59.1=pypi_0
49
+ gradio=3.23.0=pyhd8ed1ab_0
50
+ gst-plugins-base=1.18.5=h9e645db_0
51
+ gstreamer=1.18.5=hd78058f_0
52
+ h11=0.14.0=pyhd8ed1ab_0
53
+ h2=4.1.0=py38haa244fe_0
54
+ hdf5=1.10.6=nompi_he0bbb20_101
55
+ hpack=4.0.0=pyh9f0ad1d_0
56
+ httpcore=0.17.3=pyhd8ed1ab_0
57
+ httplib2=0.22.0=pypi_0
58
+ httpx=0.24.1=pyhd8ed1ab_0
59
+ huggingface_hub=0.16.4=pyhd8ed1ab_0
60
+ hyperframe=6.0.1=pyhd8ed1ab_0
61
+ icu=58.2=ha925a31_3
62
+ idna=3.4=pyhd8ed1ab_0
63
+ importlib-metadata=6.8.0=pyha770c72_0
64
+ importlib_resources=6.0.0=pyhd8ed1ab_1
65
+ intel-openmp=2023.2.0=h57928b3_49496
66
+ ipython=8.12.0=pyh08f2357_0
67
+ jbig=2.1=h8d14728_2003
68
+ jedi=0.18.2=pyhd8ed1ab_0
69
+ jinja2=3.1.2=pyhd8ed1ab_1
70
+ jpeg=9e=hcfcfb64_3
71
+ jsonschema=4.18.4=pyhd8ed1ab_0
72
+ jsonschema-specifications=2023.7.1=pyhd8ed1ab_0
73
+ jwt=1.3.1=pypi_0
74
+ kiwisolver=1.4.4=py38hb1fd069_1
75
+ lcms2=2.12=h83e58a3_0
76
+ lerc=3.0=hd77b12b_0
77
+ libblas=3.9.0=8_mkl
78
+ libcblas=3.9.0=8_mkl
79
+ libclang=12.0.0=default_h627e005_2
80
+ libdeflate=1.8=h2bbff1b_5
81
+ libffi=3.4.2=h8ffe710_5
82
+ libglib=2.76.4=he8f3873_0
83
+ libiconv=1.17=h8ffe710_0
84
+ liblapack=3.9.0=8_mkl
85
+ libogg=1.3.4=h8ffe710_1
86
+ libpng=1.6.39=h19919ed_0
87
+ libprotobuf=3.20.3=h12be248_0
88
+ libsqlite=3.42.0=hcfcfb64_0
89
+ libtiff=4.3.0=hd413186_2
90
+ libvorbis=1.3.7=h0e60522_0
91
+ libwebp=1.3.1=hcfcfb64_0
92
+ libwebp-base=1.3.1=hcfcfb64_0
93
+ libxml2=2.10.4=hc3477c8_0
94
+ libxslt=1.1.37=h0192164_0
95
+ libzlib=1.2.13=hcfcfb64_5
96
+ linkify-it-py=2.0.0=pyhd8ed1ab_0
97
+ m2w64-gcc-libgfortran=5.3.0=6
98
+ m2w64-gcc-libs=5.3.0=7
99
+ m2w64-gcc-libs-core=5.3.0=7
100
+ m2w64-gmp=6.1.0=2
101
+ m2w64-libwinpthread-git=5.0.0.4634.697f757=2
102
+ markdown-it-py=2.2.0=pyhd8ed1ab_0
103
+ markupsafe=2.1.3=py38h91455d4_0
104
+ matplotlib=3.2.2=1
105
+ matplotlib-base=3.2.2=py38hbe5506b_1
106
+ matplotlib-inline=0.1.6=pyhd8ed1ab_0
107
+ mdit-py-plugins=0.3.3=pyhd8ed1ab_0
108
+ mdurl=0.1.0=pyhd8ed1ab_0
109
+ mkl=2020.4=hb70f87d_311
110
+ msys2-conda-epoch=20160418=1
111
+ multidict=6.0.4=py38h91455d4_0
112
+ numpy=1.24.4=py38h1d91fd2_0
113
+ oauthlib=3.2.2=pypi_0
114
+ olefile=0.46=pyh9f0ad1d_1
115
+ opencv=4.6.0=py38hf11a4ad_3
116
+ opencv-contrib-python=4.8.0.74=pypi_0
117
+ openjpeg=2.5.0=hb211442_0
118
+ openssl=1.1.1u=hcfcfb64_0
119
+ orjson=3.9.2=py38he30244c_0
120
+ packaging=23.1=pyhd8ed1ab_0
121
+ pandas=2.0.3=py38hf08cf0d_1
122
+ parso=0.8.3=pyhd8ed1ab_0
123
+ patsy=0.5.3=pyhd8ed1ab_0
124
+ pcre2=10.40=h17e33f8_0
125
+ pickleshare=0.7.5=py_1003
126
+ pillow=10.0.0=pypi_0
127
+ pip=23.2.1=pyhd8ed1ab_0
128
+ pkgutil-resolve-name=1.3.10=pyhd8ed1ab_0
129
+ platformdirs=3.9.1=pyhd8ed1ab_0
130
+ ply=3.11=py_1
131
+ pooch=1.7.0=pyha770c72_3
132
+ prompt-toolkit=3.0.39=pyha770c72_0
133
+ prompt_toolkit=3.0.39=hd8ed1ab_0
134
+ protobuf=4.23.4=pypi_0
135
+ psutil=5.9.5=py38h91455d4_0
136
+ pure_eval=0.2.2=pyhd8ed1ab_0
137
+ pyasn1=0.5.0=pypi_0
138
+ pyasn1-modules=0.3.0=pypi_0
139
+ pycparser=2.21=pypi_0
140
+ pydantic=2.1.1=pyhd8ed1ab_0
141
+ pydantic-core=2.4.0=py38h4900a04_0
142
+ pydub=0.25.1=pyhd8ed1ab_0
143
+ pygments=2.15.1=pyhd8ed1ab_0
144
+ pyparsing=3.1.0=pyhd8ed1ab_0
145
+ pyqt=5.15.7=py38hd77b12b_0
146
+ pyqt5-sip=12.11.0=py38hd77b12b_0
147
+ pysocks=1.7.1=pyh0701188_6
148
+ python=3.8.17=h6244533_0
149
+ python-dateutil=2.8.2=pyhd8ed1ab_0
150
+ python-multipart=0.0.6=pyhd8ed1ab_0
151
+ python-tzdata=2023.3=pyhd8ed1ab_0
152
+ python_abi=3.8=2_cp38
153
+ pytz=2023.3=pyhd8ed1ab_0
154
+ pyyaml=6.0=py38h91455d4_5
155
+ qt-main=5.15.2=he8e5bd7_7
156
+ qt-webengine=5.15.9=hb9a9bb5_5
157
+ qtwebkit=5.212=h2bbfb41_5
158
+ referencing=0.30.0=pyhd8ed1ab_0
159
+ requests=2.31.0=pyhd8ed1ab_0
160
+ requests-oauthlib=1.3.1=pypi_0
161
+ rpds-py=0.9.2=py38h4900a04_0
162
+ rsa=4.9=pypi_0
163
+ scipy=1.10.1=py38h1aea9ed_3
164
+ seaborn=0.12.2=hd8ed1ab_0
165
+ seaborn-base=0.12.2=pyhd8ed1ab_0
166
+ semantic_version=2.10.0=pyhd8ed1ab_0
167
+ setuptools=68.0.0=pyhd8ed1ab_0
168
+ sip=6.6.2=py38hd77b12b_0
169
+ six=1.16.0=pyh6c4a22f_0
170
+ smmap=5.0.0=pypi_0
171
+ sniffio=1.3.0=pyhd8ed1ab_0
172
+ sqlite=3.42.0=hcfcfb64_0
173
+ stack_data=0.6.2=pyhd8ed1ab_0
174
+ starlette=0.27.0=pyhd8ed1ab_0
175
+ statsmodels=0.14.0=py38h634f036_1
176
+ tk=8.6.12=h8ffe710_0
177
+ toml=0.10.2=pyhd8ed1ab_0
178
+ toolz=0.12.0=pyhd8ed1ab_0
179
+ torch=1.8.1+cu101=pypi_0
180
+ torchaudio=0.8.1=pypi_0
181
+ torchvision=0.9.1+cu101=pypi_0
182
+ tornado=6.3.2=py38h91455d4_0
183
+ tqdm=4.65.0=pyhd8ed1ab_1
184
+ traitlets=5.9.0=pyhd8ed1ab_0
185
+ typing-extensions=4.7.1=hd8ed1ab_0
186
+ typing_extensions=4.7.1=pyha770c72_0
187
+ uc-micro-py=1.0.1=pyhd8ed1ab_0
188
+ ucrt=10.0.22621.0=h57928b3_0
189
+ uritemplate=4.1.1=pypi_0
190
+ urllib3=1.26.16=pypi_0
191
+ uvicorn=0.23.1=py38haa244fe_0
192
+ vc=14.3=h64f974e_17
193
+ vc14_runtime=14.36.32532=hfdfe4a8_17
194
+ vs2015_runtime=14.36.32532=h05e6639_17
195
+ wcwidth=0.2.6=pyhd8ed1ab_0
196
+ websockets=11.0.3=py38h91455d4_0
197
+ wheel=0.41.0=pyhd8ed1ab_0
198
+ win_inet_pton=1.1.0=pyhd8ed1ab_6
199
+ xz=5.2.6=h8d14728_0
200
+ yaml=0.2.5=h8ffe710_2
201
+ yarl=1.9.2=py38h91455d4_0
202
+ zipp=3.16.2=pyhd8ed1ab_0
203
+ zlib=1.2.13=hcfcfb64_5
204
+ zstd=1.5.2=h12be248_7
test.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def greet(name):
4
+ return "Hello " + name + "!!"
5
+
6
+ iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
+ iface.launch()
token_Client.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"token": "ya29.a0AbVbY6N2Zmru0NavNAh7_-U0IN-I3APMSgeQAX7GKZtSUEpHBEISfL-Lyq1AG59eCJTgikV7EFsTPt5Ik8FzFiecv52yffZK6au0CSUhOjLPx6orYdg0kLdq0Qto6y71M4L6zExR123B7iPSTLE5d11pRkfJaCgYKAXsSARMSFQFWKvPlIIdN5HLnnQFKwbuMLV_USg0163", "refresh_token": "1//0eVYT040vL_wbCgYIARAAGA4SNwF-L9Ir5V0ZjloBYUVwCuPrC39h47CgKaBJq17XDQ-XkC83XcICEZJygRqiesvTV2ls0MhM1xY", "token_uri": "https://oauth2.googleapis.com/token", "client_id": "709256034265-gpo1qcstq1dnko3rbt7md081g38lfcsb.apps.googleusercontent.com", "client_secret": "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", "scopes": ["https://www.googleapis.com/auth/drive.metadata.readonly", "https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/drive.file"], "expiry": "2023-07-29T07:07:27.463272Z"}
token_Server.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"token": "ya29.a0AbVbY6M-Dv97VYV1iSudP345jhE1G57amhC59-tq7pL7624Zl807q1RyziApexlYS2FRlOKoxJH8cl1ImbsaOfZxHorgVfe0xlgzae9heGnpYl8K-a-9IVudFta9FZe9CijpkQBM_P51V40ym5GeBQfcdI3vaCgYKAfgSARASFQFWKvPlkNUjw-YIjrbrPYbYnqrytQ0163", "refresh_token": "1//0eC3Oi53WVh3RCgYIARAAGA4SNwF-L9Ir1-KXbfTRMlb7y6OTYDhp0tPBAUZHLsKAEPZyhLt5A_7_hh4ygpINTtL0O5FpvrQr44U", "token_uri": "https://oauth2.googleapis.com/token", "client_id": "993373330768-nlm1aii22j4sek1a5ag5e2rdiagfiva9.apps.googleusercontent.com", "client_secret": "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", "scopes": ["https://www.googleapis.com/auth/drive.metadata.readonly", "https://www.googleapis.com/auth/drive", "https://www.googleapis.com/auth/drive.file"], "expiry": "2023-07-29T07:09:38.019577Z"}
yolov5s.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8b3b748c1e592ddd8868022e8732fde20025197328490623cc16c6f24d0782ee
3
+ size 14808437