Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jupyter笔记本中的HTML表单到python代码_Python_Jupyter Notebook_Google Colaboratory - Fatal编程技术网

jupyter笔记本中的HTML表单到python代码

jupyter笔记本中的HTML表单到python代码,python,jupyter-notebook,google-colaboratory,Python,Jupyter Notebook,Google Colaboratory,我可以运行除此colab页面上最后一个单元格之外的所有单元格 “在示例图像上运行”部分中有一个表单。如何使用脚本而不是该表单?我使用的Jupyter笔记本不支持创建这样的表单。如果在colab中双击表单,您可以看到其背后的代码: SAMPLE_IMAGE='image1'#@param['image1','image2','image3'] IMAGE#URL=''#@param{type:“string”} _示例URL=('https://github.com/tensorflow/mod

我可以运行除此colab页面上最后一个单元格之外的所有单元格


“在示例图像上运行”部分中有一个表单。如何使用脚本而不是该表单?我使用的Jupyter笔记本不支持创建这样的表单。

如果在colab中双击表单,您可以看到其背后的代码:

SAMPLE_IMAGE='image1'#@param['image1','image2','image3']
IMAGE#URL=''#@param{type:“string”}
_示例URL=('https://github.com/tensorflow/models/blob/master/research/'
'deeplab/g3doc/img/%s.jpg?raw=true')
def运行可视化(url):
“”“推断DeepLab模型并可视化结果。”“”
尝试:
f=urllib.request.urlopen(url)
jpeg_str=f.read()
原始im=Image.open(BytesIO(jpeg\u str))
除IOError外:
打印('无法检索图像。请检查url:'+url)
返回
打印('在图像%s上运行deeplab…。%url)
调整大小的\u im,seg\u map=MODEL.run(原始\u im)
可视切分(调整大小的切分、分段图)
image\u url=image\u url或_SAMPLE\u url%SAMPLE\u image
运行可视化(图像url)
如果您将此代码原样复制到您自己的jupyter实例中的新单元格中,您现在可以为
@param
字段填充任何您喜欢的值,并正常运行单元格