def test_caffe_import(self):
# Test 1
data = L.Input(shape={'dim': [10, 3, 224, 224]})
top = L.Python(data, module='pyloss', layer='EuclideanLossLayer', loss_weight=1, name='eucLoss')
with open(os.path.join(settings.BASE_DIR, 'media', 'test.prototxt'), 'w') as f:
f.write(str(to_proto(top)))
sample_file = open(os.path.join(settings.BASE_DIR, 'media', 'test.prototxt'), 'r')
response = self.client.post(reverse('caffe-import'), {'file': sample_file})
response = json.loads(response.content)
os.remove(os.path.join(settings.BASE_DIR, 'media', 'test.prototxt'))
self.assertGreaterEqual(len(response['net']['l1']['params']), 4)
self.assertEqual(response['result'], 'success')
# Test 2
top = L.Python(module='pascal_multilabel_datalayers', layer='PascalMultilabelDataLayerSync',
param_str="{\'pascal_root\': \'../data/pascal/VOC2007\', \'im_shape\': [227, 227], \
\'split\': \'train\', \'batch_size\': 128}")
with open(os.path.join(settings.BASE_DIR, 'media', 'test.prototxt'), 'w') as f:
f.write(str(to_proto(top)))
sample_file = open(os.path.join(settings.BASE_DIR, 'media', 'test.prototxt'), 'r')
response = self.client.post(reverse('caffe-import'), {'file': sample_file})
response = json.loads(response.content)
os.remove(os.path.join(settings.BASE_DIR, 'media', 'test.prototxt'))
self.assertGreaterEqual(len(response['net']['l0']['params']), 6)
self.assertEqual(response['result'], 'success')
评论列表
文章目录