mirror of
https://github.com/gradio-app/gradio.git
synced 2025-02-23 11:39:17 +08:00
fixed output component issues causing tests to fail
This commit is contained in:
parent
e82308eee7
commit
cf9d179794
@ -53,7 +53,7 @@ class TestCallingLoadInterface(unittest.TestCase):
|
||||
def test_image_classification_model(self):
|
||||
interface_info = gr.external.load_interface("models/google/vit-base-patch16-224")
|
||||
io = gr.Interface(**interface_info)
|
||||
output = io("images/lion.jpg")
|
||||
output = io("test/images/lion.jpg")
|
||||
self.assertGreater(output['lion'], 0.5)
|
||||
|
||||
def test_translation_model(self):
|
||||
@ -75,7 +75,7 @@ class TestCallingLoadInterface(unittest.TestCase):
|
||||
|
||||
interface_info = gr.external.load_interface("spaces/abidlabs/image-identity")
|
||||
io = gr.Interface(**interface_info)
|
||||
output = io("images/lion.jpg")
|
||||
output = io("test/images/lion.jpg")
|
||||
assertIsFile(output)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -83,7 +83,7 @@ class TestImage(unittest.TestCase):
|
||||
open_and_rotate,
|
||||
gr.inputs.Image(shape=(30, 10), type="file"),
|
||||
"image")
|
||||
output = iface.process([x_img])[0][0][0]
|
||||
output = iface.process([x_img])[0][0]
|
||||
self.assertEqual(gr.processing_utils.decode_base64_to_image(output).size, (10, 30))
|
||||
|
||||
|
||||
|
@ -62,15 +62,15 @@ class TestImage(unittest.TestCase):
|
||||
def test_as_component(self):
|
||||
y_img = gr.processing_utils.decode_base64_to_image(gr.test_data.BASE64_IMAGE)
|
||||
image_output = gr.outputs.Image()
|
||||
self.assertTrue(image_output.postprocess(y_img)[0].startswith("data:image/png;base64,iVBORw0KGgoAAA"))
|
||||
self.assertTrue(image_output.postprocess(np.array(y_img))[0].startswith("data:image/png;base64,iVBORw0KGgoAAA"))
|
||||
self.assertTrue(image_output.postprocess(y_img).startswith("data:image/png;base64,iVBORw0KGgoAAA"))
|
||||
self.assertTrue(image_output.postprocess(np.array(y_img)).startswith("data:image/png;base64,iVBORw0KGgoAAA"))
|
||||
|
||||
def test_in_interface(self):
|
||||
def generate_noise(width, height):
|
||||
return np.random.randint(0, 256, (width, height, 3))
|
||||
|
||||
iface = gr.Interface(generate_noise, ["slider", "slider"], "image")
|
||||
self.assertTrue(iface.process([10, 20])[0][0][0].startswith("data:image/png;base64"))
|
||||
self.assertTrue(iface.process([10, 20])[0][0].startswith("data:image/png;base64"))
|
||||
|
||||
class TestKeyValues(unittest.TestCase):
|
||||
def test_in_interface(self):
|
||||
|
Loading…
Reference in New Issue
Block a user