mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-12 10:34:32 +08:00
Blocks-Components
- tweaks to image
This commit is contained in:
parent
e75dda2f6e
commit
921d0b03cf
@ -941,6 +941,15 @@ class Image(Component):
|
||||
output: Type of value to be passed to component. "numpy" expects a numpy array with shape (width, height, 3), "pil" expects a PIL image object, "file" expects a file path to the saved image or a remote URL, "plot" expects a matplotlib.pyplot object, "auto" detects return type.
|
||||
label (str): component name in interface.
|
||||
"""
|
||||
if "plot" in kwargs:
|
||||
warnings.warn(
|
||||
"The 'plot' parameter has been deprecated. Set parameter 'type' to 'plot' instead.",
|
||||
DeprecationWarning,
|
||||
)
|
||||
self.type = "plot"
|
||||
else:
|
||||
self.type = type
|
||||
|
||||
self.type = type
|
||||
self.shape = shape
|
||||
self.image_mode = image_mode
|
||||
@ -965,6 +974,8 @@ class Image(Component):
|
||||
"shape": (28, 28),
|
||||
"invert_colors": True,
|
||||
},
|
||||
"plot": {"type": "plot"},
|
||||
"pil": {"type": "pil"},
|
||||
}
|
||||
|
||||
def get_template_context(self):
|
||||
@ -1154,9 +1165,6 @@ class Image(Component):
|
||||
return test_data.BASE64_IMAGE
|
||||
|
||||
# Output functions
|
||||
@classmethod
|
||||
def get_shortcut_implementations(cls):
|
||||
return {"image": {}, "plot": {"type": "plot"}, "pil": {"type": "pil"}}
|
||||
|
||||
def postprocess(self, y):
|
||||
"""
|
||||
@ -1200,6 +1208,5 @@ class Image(Component):
|
||||
y = processing_utils.decode_base64_to_file(x).name
|
||||
return y
|
||||
|
||||
|
||||
def restore_flagged(self, dir, data, encryption_key):
|
||||
return self.restore_flagged_file(dir, data, encryption_key)["data"]
|
||||
|
@ -58,14 +58,10 @@ class Image(Image):
|
||||
plot (bool): DEPRECATED. Whether to expect a plot to be returned by the function.
|
||||
label (str): component name in interface.
|
||||
"""
|
||||
if plot:
|
||||
warnings.warn(
|
||||
"The 'plot' parameter has been deprecated. Set parameter 'type' to 'plot' instead.",
|
||||
DeprecationWarning,
|
||||
)
|
||||
self.type = "plot"
|
||||
else:
|
||||
self.type = type
|
||||
warnings.warn(
|
||||
"Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components",
|
||||
DeprecationWarning,
|
||||
)
|
||||
super().__init__(label=label, type=type, plot=plot)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user