Coder Social home page Coder Social logo

deep-learning-knee's People

Contributors

nimazarei888 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

deep-learning-knee's Issues

setup

setup(
name='ouludeepknee',
version='0.1',
author=nima zarei
packages=find_packages(),
include_package_data=True,
license='LICENSE.txt',
long_description=open('README.md').read(),
)

Readme

About

The software in this branch implements an automatic pipeline for osteoarthritis severity assessment from plain radiographs.
It can be utilized via REST over HTTP or DICOM protocols. Furthermore, we have built a web UI that is easy to use.

analyse sistem

-- coding: utf-8 --

import glob
import argparse
import requests
import os
import base64
import cv2
import pandas as pd
import numpy as np
from tqdm import tqdm

def base64tonumpy(buffer):
binary = base64.b64decode(buffer)

img = cv2.imdecode(np.fromstring(binary, dtype=np.uint8), cv2.IMREAD_COLOR)
return img

if name == "main":
parser = argparse.ArgumentParser()
parser.add_argument('--deepknee_host', default='http://127.0.0.1', help='Host on which deepknee is running.')
parser.add_argument('--deepknee_port', type=int, default=5001, help='Port of deepknee.')
parser.add_argument('--img_dir', default='', help='Directory with images.')
parser.add_argument('--patient_level', type=bool, default=False,
help='Whether there image lies in a patient directory. '
'In this case, the script will know that the img_dir '
'contains folders that contain images.')
parser.add_argument('--save_results', default='/tmp/deepknee', help='Folder where to save the results.')
args = parser.parse_args()

url = f'{args.deepknee_host}:{args.deepknee_port}/deepknee/predict/bilateral'
os.makedirs(args.save_results, exist_ok=True)
output_csv = []
if not args.patient_level:
    flist = glob.glob(os.path.join(args.img_dir, '*'))
else:
    flist = glob.glob(os.path.join(args.img_dir, '*', '*'))

for idx, img_path in tqdm(enumerate(flist), total=len(flist)):
    # Encoding the DICOM as base64 and sending the request to the server
    with open(img_path, 'rb') as f:
        data_base64 = base64.b64encode(f.read()).decode('ascii')
    response = requests.post(url, json={'dicom': data_base64})
    res = response.json()
    # Parsing the response
    result = {}
    for knee in 'LR':
        # You can also access the localized image, heatmaps and the probability maps
        result[knee] = {'img': base64tonumpy(res[knee]['img']),
                        'hm': base64tonumpy(res[knee]['hm']),
                        'probs_bar': base64tonumpy(res[knee]['preds_bar']),
                        'kl': res[knee]['kl']}
        output_csv.append({'File': img_path, 'Side': knee, 'KL': result[knee]['kl']})
        cv2.imwrite(os.path.join(args.save_results, f'{idx}_{knee}_img.png'), result[knee]['img'])
        cv2.imwrite(os.path.join(args.save_results, f'{idx}_{knee}_hm.png'), result[knee]['hm'])
        cv2.imwrite(os.path.join(args.save_results, f'{idx}_{knee}_probs.png'), result[knee]['probs_bar'])

df = pd.DataFrame(data=output_csv)
df.to_csv(os.path.join(args.save_results, 'deepknee.csv'), index=None)

Run deepknee

mkdir -p logs
KNEEL_ADDR=http://127.0.0.1:5000 python -m ouludeepknee.inference.app
--snapshots_path snapshots_knee_grading/
--device cpu --deploy True
--port 6001
--logs logs/deepknee-cpu.log

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.