mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-03 01:50:59 +08:00
78 lines
15 KiB
Python
78 lines
15 KiB
Python
import numpy as np
|
|
import unittest
|
|
import os
|
|
from gradio import outputs
|
|
import json
|
|
|
|
PACKAGE_NAME = 'gradio'
|
|
BASE64_IMG = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wgARCADIAMgDASIAAhEBAxEB/8QAHAAAAQUBAQEAAAAAAAAAAAAABQACAwQGBwEI/8QAGgEAAwEBAQEAAAAAAAAAAAAAAQIDBAAFBv/aAAwDAQACEAMQAAAB09a1OqDQ98RNiD50j1JoWICkgVvMXUcqCNvqPJeNIQ++Pr0KuXmGfJPfPrQvUA6AQpUg3Y6OqBCz2SJZ7N5Zm+SPp0Escx6s70WQRK41/dsKw2yVmDkAUiVmgur0womMbrYuzSqrUxSYuMvBGByxWsSerPHXBJz0n2aZ9bZMc8C3cKvk3alA87zHa8Y84KNW2JzFKJlKV/S8LvkZSYpc70xBb1K88NddNM7i2kEpht+eWSLVZsMlNmsWaSpmvjLxGiHz01bl10e/Tl6IaFl3kUC2IVtWyW9wCJOqyAukhJrPR7/GHrftey1JfYIqcsz0gOpyxw2wPzIwXeDOpcwoxEUd7Rn6cWpvpH2KKdNA/Nkxxz2kLStNpc5pM95JLUnAfa8usaflqiwJ5keBTT0Gnnx3NptDzyUd0jOvyQnZNS31sUhtxb/JF21YlTMiSNEKKU6cm9KF0OTVIvYxK3XdHZYxRd3NjrwXRi5qvk5zRwq1kk4uOD6V82vkgs5wfhmh9LNWkjizPmXtuHqCDKnbsyNI47vv86o7cvSPMdRou0pi6C9eEKston5CG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kAu/ETZavN8y4KRxA4HOpXLpcXLHfjiNWtUS0zHUagOytQXOYCsFC1w7yr0QChKQsyO+D7iCnXcptgGt25cVcS7IrXgDl4IBVcDBOO24pCMqKMy/Ur7F/Id0xmMvxbcyC0OdxHDMFK8wbQFYHLm8TOE+xjleCcKZNppuxx6uJYGXUUL/qFc7ifCA88P9wN24aDH4nRHuJzC9HvzKOZxeYt3cFlgt+Dn6oyf4AUOiF6EzVdgmkDt3cXJNsv3IgMmaT4A/sFYQSAWfgP3CzLe2MDELXlqCAACeiXhcR6CM/lAdHB9Tww34CZ5xxcHXzBgAMBL7lOpvngGnbwRXN5ZYc/4q8Vpe0KYja1YHSQrvVkFolzH0y0a+UZCCJL01aXYMflgUS4iRY59Db+oroS/6bVt1Hq/1N9IuCMAdA7ZcrvMnuY8xC84lgz4RM/0w/wCtT//2Q=="
|
|
|
|
|
|
class TestLabel(unittest.TestCase):
|
|
def test_path_exists(self):
|
|
out = outputs.Label()
|
|
path = outputs.BASE_OUTPUT_INTERFACE_TEMPLATE_PATH.format(out.get_name())
|
|
self.assertTrue(os.path.exists(os.path.join(PACKAGE_NAME, path)))
|
|
|
|
def test_postprocessing_string(self):
|
|
string = 'happy'
|
|
out = outputs.Label()
|
|
label = json.loads(out.postprocess(string))
|
|
self.assertDictEqual(label, {outputs.Label.LABEL_KEY: string})
|
|
|
|
def test_postprocessing_1D_array(self):
|
|
array = np.array([0.1, 0.2, 0, 0.7, 0])
|
|
true_label = {outputs.Label.LABEL_KEY: 3,
|
|
outputs.Label.CONFIDENCES_KEY: [
|
|
{outputs.Label.LABEL_KEY: 3, outputs.Label.CONFIDENCE_KEY: 0.7},
|
|
{outputs.Label.LABEL_KEY: 1, outputs.Label.CONFIDENCE_KEY: 0.2},
|
|
{outputs.Label.LABEL_KEY: 0, outputs.Label.CONFIDENCE_KEY: 0.1},
|
|
]}
|
|
out = outputs.Label()
|
|
label = json.loads(out.postprocess(array))
|
|
self.assertDictEqual(label, true_label)
|
|
|
|
def test_postprocessing_1D_array_no_confidences(self):
|
|
array = np.array([0.1, 0.2, 0, 0.7, 0])
|
|
true_label = {outputs.Label.LABEL_KEY: 3}
|
|
out = outputs.Label(show_confidences=False)
|
|
label = json.loads(out.postprocess(array))
|
|
self.assertDictEqual(label, true_label)
|
|
|
|
def test_postprocessing_int(self):
|
|
true_label_array = np.array([[[3]]])
|
|
true_label = {outputs.Label.LABEL_KEY: 3}
|
|
out = outputs.Label()
|
|
label = json.loads(out.postprocess(true_label_array))
|
|
self.assertDictEqual(label, true_label)
|
|
|
|
|
|
class TestTextbox(unittest.TestCase):
|
|
def test_path_exists(self):
|
|
out = outputs.Textbox()
|
|
path = outputs.BASE_OUTPUT_INTERFACE_TEMPLATE_PATH.format(out.get_name())
|
|
self.assertTrue(os.path.exists(os.path.join(PACKAGE_NAME, path)))
|
|
|
|
def test_postprocessing(self):
|
|
string = 'happy'
|
|
out = outputs.Textbox()
|
|
string = out.postprocess(string)
|
|
self.assertEqual(string, string)
|
|
|
|
|
|
class TestImage(unittest.TestCase):
|
|
def test_path_exists(self):
|
|
out = outputs.Image()
|
|
path = outputs.BASE_OUTPUT_INTERFACE_TEMPLATE_PATH.format(out.get_name())
|
|
self.assertTrue(os.path.exists(os.path.join(PACKAGE_NAME, path)))
|
|
|
|
def test_postprocessing(self):
|
|
string = BASE64_IMG
|
|
out = outputs.Textbox()
|
|
string = out.postprocess(string)
|
|
self.assertEqual(string, string)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|