guru001's picture
init
1f77b91
raw
history blame
1.79 kB
import os
import boto3
from io import BytesIO , StringIO
import pickle as pkl
from utils import *
def get_data_s3(filename):
ACCESS_KEY = "AKIAUKUH7S3OIVOEIRWY"
SECRET_KEY = "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"
bucket = "root-models"
s3 = boto3.client( "s3" , aws_access_key_id=ACCESS_KEY , aws_secret_access_key=SECRET_KEY )
response = s3.get_object(Bucket=bucket, Key=filename)
data = BytesIO( response["Body"].read() )
return data
def parse_cfg_url(filename='yolov3.cfg'):
data = get_data_s3(filename)
lines = data.getvalue().decode().rstrip().lstrip().split('\n') #store the lines in a list
lines = [x.rstrip().lstrip() for x in lines]
lines = [x for x in lines if len(x) > 0] #get read of the empty lines
lines = [x for x in lines if x[0] != '#']
lines = [x.rstrip().lstrip() for x in lines]
block = {}
blocks = []
for line in lines:
# print('line:' , line)
if line[0] == "[": #This marks the start of a new block
if len(block) != 0:
blocks.append(block)
block = {}
block["type"] = line[1:-1].rstrip()
else:
key,value = line.split("=")
block[key.rstrip()] = value.lstrip()
blocks.append(block)
# print('blocks : 2 ' , blocks )
return blocks
if __name__ == '__main__':
# parse_cfg('yolov3.cfg')
# parse_cfg_url('yolov3.cfg')
# colors = pkl.load( open( "pallete", "rb") )
# print(colors)
# print()
# colors = pkl.load( get_data_s3( "pallete" ) )
# print(colors)
classes = load_classes('data/coco.names')
print( classes )
print()
classes = load_classes_url('coco.names')
print( classes )