Merge branch 'master' of github.com:gradio-app/gradio

t push# Please enter a commit message to explain why this merge is necessary,
This commit is contained in:
aliabd 2020-11-04 23:14:26 +04:00
commit 97d8444514
4 changed files with 7 additions and 7 deletions

View File

@ -75,7 +75,7 @@ h4 {
cursor: pointer; cursor: pointer;
} }
.examples > button { .examples > button {
padding: 4px; padding: 8px 16px;
border-radius: 2px; border-radius: 2px;
margin-right: 4px; margin-right: 4px;
background-color: whitesmoke; background-color: whitesmoke;

View File

@ -44,4 +44,4 @@ io = gr.Interface(
] ]
) )
io.launch(share=True) io.launch()

View File

@ -75,7 +75,7 @@ h4 {
cursor: pointer; cursor: pointer;
} }
.examples > button { .examples > button {
padding: 4px; padding: 8px 16px;
border-radius: 2px; border-radius: 2px;
margin-right: 4px; margin-right: 4px;
background-color: whitesmoke; background-color: whitesmoke;

View File

@ -10,7 +10,7 @@ class TestDefault(unittest.TestCase):
def test_default_text(self): def test_default_text(self):
max_word_len = lambda text: max([len(word) for word in text.split(" ")]) max_word_len = lambda text: max([len(word) for word in text.split(" ")])
text_interface = Interface(max_word_len, "textbox", "label", interpretation="default") text_interface = Interface(max_word_len, "textbox", "label", interpretation="default")
interpretation = text_interface.interpret(["quickest brown fox"])[0] interpretation = text_interface.interpret(["quickest brown fox"])[0][0]
self.assertGreater(interpretation[0][1], 0) # Checks to see if the first word has >0 score. self.assertGreater(interpretation[0][1], 0) # Checks to see if the first word has >0 score.
self.assertEqual(interpretation[-1][1], 0) # Checks to see if the last word has 0 score. self.assertEqual(interpretation[-1][1], 0) # Checks to see if the last word has 0 score.
@ -20,7 +20,7 @@ class TestDefault(unittest.TestCase):
array = np.zeros((100,100)) array = np.zeros((100,100))
array[0, 0] = 1 array[0, 0] = 1
img = encode_array_to_base64(array) img = encode_array_to_base64(array)
interpretation = img_interface.interpret([img])[0] interpretation = img_interface.interpret([img])[0][0]
self.assertGreater(interpretation[0][0], 0) # Checks to see if the top-left has >0 score. self.assertGreater(interpretation[0][0], 0) # Checks to see if the top-left has >0 score.
@ -29,14 +29,14 @@ class TestCustom(unittest.TestCase):
max_word_len = lambda text: max([len(word) for word in text.split(" ")]) max_word_len = lambda text: max([len(word) for word in text.split(" ")])
custom = lambda text: [(char, 1) for char in text] custom = lambda text: [(char, 1) for char in text]
text_interface = Interface(max_word_len, "textbox", "label", interpretation=custom) text_interface = Interface(max_word_len, "textbox", "label", interpretation=custom)
result = text_interface.interpret(["quickest brown fox"])[0] result = text_interface.interpret(["quickest brown fox"])[0][0]
self.assertEqual(result[0][1], 1) # Checks to see if the first letter has score of 1. self.assertEqual(result[0][1], 1) # Checks to see if the first letter has score of 1.
def test_custom_img(self): def test_custom_img(self):
max_pixel_value = lambda img: img.max() max_pixel_value = lambda img: img.max()
custom = lambda img: img.tolist() custom = lambda img: img.tolist()
img_interface = Interface(max_pixel_value, "image", "label", interpretation=custom) img_interface = Interface(max_pixel_value, "image", "label", interpretation=custom)
result = img_interface.interpret([gradio.test_data.BASE64_IMAGE])[0] result = img_interface.interpret([gradio.test_data.BASE64_IMAGE])[0][0]
expected_result = np.asarray(decode_base64_to_image(gradio.test_data.BASE64_IMAGE).convert('RGB')).tolist() expected_result = np.asarray(decode_base64_to_image(gradio.test_data.BASE64_IMAGE).convert('RGB')).tolist()
self.assertEqual(result, expected_result) self.assertEqual(result, expected_result)