Exemplo n.º 1
0
def main():
    #if len(sys.argv) < 2:
    #    print("usage: python %prog <torrent> [options]")
    #    return

    opts = optparse.OptionParser(\
        usage = "usage: python console.py <torrent> [options]")
    opts.add_option('-s', '--store', action = 'store_true', \
                        dest = 'store', help = 'files are written to disk')
    opts.add_option('-p', '--path', default = 'downloads', dest = 'path',\
      metavar = 'DIR', help = 'in which dir to store/retrieve the files')
    opts.add_option('-a', '--accept', action = 'store_true', \
      dest = 'accept', help = 'starts listening for incoming connections')

    options, args = opts.parse_args()
    if len(args) != 1:
        opts.error('incorrect number of arguments')

    peer_id = b'a0b1c2d3e4f5g6h7i8j9'
    env = environment.initialize(args[0], peer_id, \
                                     options.store, options.path)
    console = code.InteractiveConsole(env)

    console.interact(
        "Python interactive console %s.\nBitTorrent chat client using bitless."
        % sys.version)

    environment.shutdown()
    print("Finished...")
Exemplo n.º 2
0
def main():
    #if len(sys.argv) < 2:
    #    print("usage: python %prog <torrent> [options]")
    #    return

    opts = optparse.OptionParser(\
        usage = "usage: python console.py <torrent> [options]")
    opts.add_option('-s', '--store', action = 'store_true', \
                        dest = 'store', help = 'files are written to disk')
    opts.add_option('-p', '--path', default = 'downloads', dest = 'path',\
      metavar = 'DIR', help = 'in which dir to store/retrieve the files')
    opts.add_option('-a', '--accept', action = 'store_true', \
      dest = 'accept', help = 'starts listening for incoming connections')

    options, args = opts.parse_args()
    if len(args) != 1:
        opts.error('incorrect number of arguments')

    peer_id = b'a0b1c2d3e4f5g6h7i8j9'
    env = environment.initialize(args[0], peer_id, \
                                     options.store, options.path)
    console = code.InteractiveConsole(env)
    
    console.interact("Python interactive console %s.\nBitTorrent chat client using bitless." % sys.version)

    environment.shutdown()
    print("Finished...")
Exemplo n.º 3
0
//= Sola丶小克
//===== Current Version: ===================================== 
//= 1.0
//===== Description: ========================================= 
//= 此脚本用于编译复兴前和复兴后 Release 版本的 Pandas 模拟器
//= 符号文件的储存和上传工作, 将由其他脚本来实现
//===== Additional Comments: ================================= 
//= 1.0 首个版本. [Sola丶小克]
//============================================================
'''

# -*- coding: utf-8 -*-

import environment

environment.initialize()

import os
import platform
import re
import shutil
import time
import winreg

import git

from dotenv import load_dotenv
from libs import Common, Inputer, Message

# 切换工作目录为脚本所在目录
os.chdir(os.path.split(os.path.realpath(__file__))[0])
Exemplo n.º 4
0
def cxr_predict(hmp_dims=None,
                dcm_file=None,
                cuda='0',
                fl_gradcam=True,
                Nens=3,
                th_gradcam=0.7,
                input_type='dicom'):

    print(
        "\n-------------------------------------------------------------------"
    )
    print(
        "|                                                                 |")
    print(
        "|                                                                 |")
    print(
        "|     v1.0 MGH Age, View, Gender, Vendor, Abnormal Detection      |")
    print(
        "|    (Copyright (c) 2021-2022, MGH LMIC. All rights reserved.)    |")
    print(
        "|                                                                 |")
    print(
        "|                                                                 |")
    print(
        "-------------------------------------------------------------------\n"
    )

    param_cuda = cuda
    param_labels = [
        'ap', 'pa', 'female', 'male', 'varian', 'agfa', 'ge',
        'Foreign body>.>.', 'Hilar/mediastinum>Cardiomegaly>.',
        'Lung density>Increased lung density>Atelectasis',
        'Lung density>Increased lung density>Pulmonary edema',
        'Lung density>Increased lung density>pneumonia',
        'Pleura>Pleural effusion>.', 'abnormal', 'PatientAge'
    ]
    param_path = None
    param_runDir = ''
    param_type = 0
    param_preModel = 'multitask_model'
    param_gradcam = fl_gradcam
    param_arch = None
    param_task = 2
    param_clsGcam = param_labels[-8:-2]
    param_Nens = Nens
    fl_ensemble = False if param_Nens == 1 else True

    runtime_path, device = initialize(param_runDir, param_cuda)

    # image preprocessing
    d = DcmToPng(
        param_labels,
        dcm_path=runtime_path.joinpath('input_dir/DICOM').resolve(),
        png_path=runtime_path.joinpath('input_dir/IMAGEFILE').resolve(),
        ds=dcm_file,
        localOp=True,
        input_type=input_type)
    #d = DcmToPng(param_labels, dcm_path=runtime_path.joinpath('dicoms').resolve(), png_path=runtime_path.joinpath('pngs').resolve(), ds=dcm_file)
    if input_type == 'dicom':
        d.dcm2png()

    # start network inference
    env = DemoEnvironment(device,
                          runtime_path,
                          mtype=param_type,
                          name_labels=param_labels,
                          name_paths=param_path,
                          name_model=param_arch,
                          task_type=param_task)
    t = Demo(env,
             pt_runtime=runtime_path,
             fn_net=param_preModel,
             fl_gradcam=param_gradcam,
             cls_gradcam=param_clsGcam,
             th_gradcam=th_gradcam,
             fl_ensemble=fl_ensemble)

    if (fl_ensemble):
        result = t.demo_cxr_ensemble_evaluation(hmp_dims=hmp_dims,
                                                n_ens=param_Nens)
    else:
        result = t.demo_cxr_evaluation(hmp_dims=hmp_dims)

    df_prob = pd.DataFrame(result['prob'], columns=print_label_name)
    df_pred = pd.DataFrame(result['pred'], columns=print_label_name)
    df_file = pd.read_csv(
        runtime_path.joinpath('input_dir/IMAGEFILE/images.csv'))
    df_prob['file'] = df_file['PATH']
    df_pred['file'] = df_file['PATH']

    runtime_path.joinpath('output_dir/Classification').mkdir(parents=True,
                                                             exist_ok=True)
    df_prob.to_csv(
        runtime_path.joinpath('output_dir/Classification/probability.txt'),
        header=True,
        index=True,
        sep=',',
        mode='w')
    df_pred.to_csv(
        runtime_path.joinpath('output_dir/Classification/prediction.txt'),
        header=True,
        index=True,
        sep=',',
        mode='w')

    #print(result)
    return result