コード例 #1
0
async def scan(file: UploadFile = File(...)):
    content_type = file.content_type
    file_name = file.filename

    # Get Image
    if content_type == 'application/pdf':
        # Get Image from 1st page of pdf
        pages = convert_from_bytes(file.file.read())
        image = pages[0]
        file_name = file_name[:-3] + '.png'
    elif content_type.startswith('image'):
        image = Image.open(file.file)
    else:
        # Return error if Unknown file
        return Response(status_code=422)

    # Scan with CUTIE
    xlsx_path = predict(image, file_name)
    return xlsx_path
コード例 #2
0
def predict_startup():
    """
    this function will be invoked by AI SW with CPP
    The target of this functoin is used to, including
        1. Initialize the Python environment
        2. Load trained weight file
        3. Completed others, including creating debug files, etc.
    """
            
    #check environment
    env.config_env()
        
    pre = predict.predict()
    pre.load_model()
        
    
    scserv  = SCServer(config.configured_TCP_server_port, pre)
      
    scserv.start() 
コード例 #3
0
def predictImg(path):
    result = predict.predict(path)[0]
    temp = result[:]
    temp = temp.argsort()[-3:][::-1]
    return {
        'top1': {
            'name': dog_breeds[temp[0]],
            'percent': "{:.2f}".format(result[temp[0]] * 100),
            'detail': description[temp[0]],
        },
        'top2': {
            'name': dog_breeds[temp[1]],
            'percent': "{:.2f}".format(result[temp[1]] * 100),
            'detail': description[temp[1]],
        },
        'top3': {
            'name': dog_breeds[temp[2]],
            'percent': "{:.2f}".format(result[temp[2]] * 100),
            'detail': description[temp[2]],
        },
    }
コード例 #4
0
def heart_predict(request):
    val = predict.predict(fin)
    return render(request, "prediction/result.html", {'fin': val})