Example #1
0
File: base.py Project: Puwong/MiMac
 def _add_alg():
     cd_alg = AlgService(db).create(title=u'猫狗二分类',
                                    base=BaseAlgorithm.BiClass,
                                    config=json.dumps({
                                        'class_cnt':
                                        2,
                                        'labels': [u'这是一只猫', u'这是一条狗']
                                    }))
     AlgService(db).create(title=u'肺部CT图像肺结节良恶性诊断',
                           base=BaseAlgorithm.BiClass,
                           config=json.dumps({
                               'class_cnt': 2,
                               'labels': [u'良性肺结节', u'恶性肺结节']
                           }))
     AlgService(db).create(title=u'乳腺钼靶X线图像良恶性诊断',
                           base=BaseAlgorithm.BiClass,
                           config=json.dumps({
                               'class_cnt': 2,
                               'labels': [u'良性乳腺', u'恶性乳腺']
                           }))
     alg_path = AlgService(db).get_alg_path(cd_alg)
     copyfile(alg_path + '/../../deeplearn/b_c_basic.json',
              alg_path + '/model.json')
     copyfile(alg_path + '/../../deeplearn/b_c_cat_dog.h5',
              alg_path + '/weight.h5')
Example #2
0
File: alg.py Project: Puwong/MiMac
 def get(self):
     return current_app.make_response(
         render_template(
             'algs.html',
             algs=AlgService(db).get_all(),
             base_alg=BaseAlgorithm.AlgDict,
             my_algs=AlgService(db).get_my_alg_ids(),
         ))
Example #3
0
File: alg.py Project: Puwong/MiMac
 def post(self):
     title = request.form.get('title')
     base = request.form.get('base')
     labels = request.form.get('labels').split(' ')
     if exists_query(Alg.query.filter_by(title=title)):
         return "There is already a algorithm named {}".format(title)
     AlgService(db).create(title=title,
                           base=base,
                           config=json.dumps({
                               'class_cnt': len(labels),
                               'labels': labels
                           }))
     return current_app.make_response(redirect(url_for('Alg.algs')))
Example #4
0
 def post(self):
     from my_app.common.tools import get_user_file_path, allowed_file, resize_img
     from my_app.tasks import predict
     if not request.form.get('alg'):
         return current_app.make_response(
             render_template(
                 'upload.html',
                 result='ERROR! Please pick up at least one algorithm',
                 algs=AlgService(db).get_my_alg_ids(with_title=True)))
     if 'file' not in request.files:
         return current_app.make_response(
             render_template(
                 'upload.html',
                 result='ERROR! file not found',
                 algs=AlgService(db).get_my_alg_ids(with_title=True)))
     file = request.files['file']
     # if user does not select file, browser also
     # submit a empty part without filename
     if file.filename == '':
         return current_app.make_response(
             render_template(
                 'upload.html',
                 result="ERROR! filename shouldn't be empty",
                 algs=AlgService(db).get_my_alg_ids(with_title=True)))
     if file and allowed_file(file.filename):
         owner = UserService(db).get(g.user_id)
         fr = ImageUserRelationship(isOwner=True)
         fr.image = Image(title=secure_filename(file.filename),
                          alg=AlgService(db).get(
                              int(request.form.get('alg'))))
         owner.images.append(fr)
         db.session.add(owner)
         db.session.commit()
         fr.image.uri = get_user_file_path(fr.image.id)
         db.session.commit()
         file.save(fr.image.store_uri)
         ImageService(db).create_tiny(fr.image)
         ImageService.create_label(fr.image)
         predict.delay(fr.image.id)
         return current_app.make_response(
             render_template(
                 'upload.html',
                 result='Upload success',
                 algs=AlgService(db).get_my_alg_ids(with_title=True)))
     else:
         return current_app.make_response(
             render_template(
                 'upload.html',
                 result=
                 "We only support dcm, dicm, png, jpg, jpeg, gif suffix now",
                 algs=AlgService(db).get_my_alg_ids(with_title=True)))
Example #5
0
File: alg.py Project: Puwong/MiMac
 def post(self):
     a_ids = request.form.get('a_id').split(' ')
     for a_id in a_ids:
         AlgService(db).add2user(int(a_id))
     return current_app.make_response(redirect(url_for('Alg.algs')))
Example #6
0
File: alg.py Project: Puwong/MiMac
 def get(self, id):
     alg = AlgService(db).get(id)
     db.session.delete(alg)
     db.session.commit()
     return current_app.make_response(redirect(url_for('Alg.algs')))
Example #7
0
 def get(self):
     return current_app.make_response(
         render_template(
             'upload.html',
             algs=AlgService(db).get_my_alg_ids(with_title=True)))