<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ryo Shimizu on Medium]]></title>
        <description><![CDATA[Stories by Ryo Shimizu on Medium]]></description>
        <link>https://medium.com/@shi3z?source=rss-91eccd4b1e2c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*pCdsNKYYjbZ6mbp08Phq4w.png</url>
            <title>Stories by Ryo Shimizu on Medium</title>
            <link>https://medium.com/@shi3z?source=rss-91eccd4b1e2c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 07:17:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shi3z/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[User Illusion, and Information vs. Exformation]]></title>
            <link>https://medium.com/@shi3z/user-illusion-and-information-vs-exformation-6e270c069941?source=rss-91eccd4b1e2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/6e270c069941</guid>
            <category><![CDATA[design]]></category>
            <dc:creator><![CDATA[Ryo Shimizu]]></dc:creator>
            <pubDate>Fri, 17 May 2019 15:29:40 GMT</pubDate>
            <atom:updated>2019-05-17T15:29:40.756Z</atom:updated>
            <content:encoded><![CDATA[<h3>User Illusion; the root of User Interface, and Information vs. Exformation.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YCSdk1NYe3NaAOD_dpmAfQ.png" /></figure><p>The concept of the user illusion which Alan Kay et al. Considered at PARC in the 1960s, was reinterpreted as a modern philosophical concept by the Danish philosopher Tor Nørretranders in 1991, about 20 years later. The</p><p>At this time, an important concept to explain the “user illusion” introduced by Nørretranders is the information to information.</p><p>“Exformation” means something that is intentionally omitted from the information.</p><p>In principle, the less information transmitted, the better. If you don’t share the person who can communicate and enough context (context, environmental knowledge), it will be transmitted incorrectly.</p><p>Therefore, information means information that is intentionally omitted according to the other party.</p><p>A well-known example of ultimately compressed information is<br>To hear the sales of his book, Les Miserables, Victor Hugo, a poor writer, in 1862 sent a telegram of only one letter to the publisher.</p><p>This is a lousy measure because the number of characters charged the telegram at that time, and we wanted to reduce the number of characters as much as possible.</p><p>The publisher sent back only one “!” Character to indicate that it was showing unexpected sales.</p><p>This case is also an example of sharing the information between Hugo and the publisher and requiring only minimal information.</p><p>Between the computer and an ordinary human, there is no such exchange. Engineers spend a great deal of time learning about computers, sharing information, and finally issuing commands.</p><p>Alan Kay, who tried to create a computer that can use “ordinary people”, has things and rules of the real world that “ordinary people” would naturally have, such as “desks and folders,” By imitating (especially called metaphor), I considered using the “normal human” ‘s exformation. The aforementioned is the expected effect of introducing metaphor.</p><p>From this flow connects to the skeuomorphism that symbolizes (icons) things in the real world and makes textures and shapes resemble. Skeuomorphism can interpret as a method of sharing more exformation by visually reproducing “old-fashioned things” that “ordinary people” know well.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6e270c069941" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Try ONNX  pre-trained model with tensorflow]]></title>
            <link>https://medium.com/@shi3z/try-onnx-pre-trained-model-with-tensorflow-df54b1514b4b?source=rss-91eccd4b1e2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/df54b1514b4b</guid>
            <category><![CDATA[tensorflow]]></category>
            <dc:creator><![CDATA[Ryo Shimizu]]></dc:creator>
            <pubDate>Thu, 25 Oct 2018 01:59:42 GMT</pubDate>
            <atom:updated>2018-10-25T02:00:43.564Z</atom:updated>
            <content:encoded><![CDATA[<h3>Try ONNX pre-trained model with tensorflow</h3><p>I’m curious about why Microsoft make me disappoint!</p><p>They call their Python module as &#39;onnxruntime&#39;.</p><p>But It only supports for Linux!(<a href="https://pypi.org/project/onnxruntime/#files">https://pypi.org/project/onnxruntime/#files</a>)<br>And I couldn&#39;t find any source codes about it.</p><p>If you using ordinary notebook computer, you couldn&#39;t try ONNXRUNTIME. Awesome!</p><p>Nobody be a happy by Microsoft&#39;s code.</p><p>So, I tried to use experimental function of TensorFlow.</p><pre>$ pip install tensorflow<br>$ pip install onnx-tf</pre><p>It is very easy to use.</p><pre>import onnx<br>from onnx_tf.backend import prepare<br>import numpy as np<br>from PIL import Image</pre><pre>model = onnx.load(&#39;vgg19/model.onnx&#39;) # Load the ONNX file</pre><pre>tf_model = prepare(model) # Import the ONNX model to Tensorflow</pre><pre>img = Image.open(&#39;input.jpg&#39;).resize((224, 224))<br>img = np.asarray(img, dtype=np.float32)[np.newaxis, np.newaxis, :, :]<br>img = img.transpose(0,1,4,2,3)<br>img = img.reshape(1,3,224,224) # Transform to Input Tensor</pre><pre>Y = tf_model.run(img)[0][0] #Inference</pre><p>You can get [1,1000] ndarray from this simple code.</p><p>At last, we can forget everything that has happened between us and ONNXRUNTIME.</p><p>You can get full code of this example from <a href="https://github.com/shi3z/onnx-example/blob/master/image_classification_tf.py">https://github.com/shi3z/onnx-example/blob/master/image_classification_tf.py</a></p><p>ONNX is not bad, but not satisfied.</p><p>But ONNX can only define the shape of input tensor and output tensor.</p><p>I guess we need more sophisticated way to use output tensor.</p><p>For example, ONNX model zoo isn&#39;t include label information.</p><p>So I had to find a labels from ILSVRC2014.</p><p>We need more better and simple way to share models and inferences.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df54b1514b4b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TinyYOLOv2 on onnx]]></title>
            <link>https://medium.com/@shi3z/tinyyolov2-on-onnx-80828fcf71e1?source=rss-91eccd4b1e2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/80828fcf71e1</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[onnx]]></category>
            <dc:creator><![CDATA[Ryo Shimizu]]></dc:creator>
            <pubDate>Sat, 20 Oct 2018 05:35:44 GMT</pubDate>
            <atom:updated>2018-10-20T05:35:44.862Z</atom:updated>
            <content:encoded><![CDATA[<p>ONNX is a open model data format for deep neural networks.</p><p>You can browse and use several robust pretrained model from <a href="https://github.com/onnx/models">onnx model zoo</a>.</p><p>Microsoft announced “ONNX Runtime” it’s seems to be easy to use with pre-trained model.</p><p><a href="https://docs.microsoft.com/en-gb/python/api/overview/azure/onnx/intro?view=azure-onnx-py">https://docs.microsoft.com/en-gb/python/api/overview/azure/onnx/intro?view=azure-onnx-py</a></p><p>But their sample code is terrible and nonsense.</p><pre>import onnxruntime as rt<br>sess = rt.InferenceSession(&quot;model.onnx&quot;)<br>input_name = sess.get_inputs()[0].name<br>pred_onnx = sess.run(None, {input_name: X})</pre><p>If you have a basic knowledge of Python, you can understand about this code snippet is not work.</p><p>Because nobody define the X.</p><p>I upset when saw this code!<br>And I angry about to Microsoft provide such a terrible code example.</p><p>So I wrote a small example for Tiny_YOLOv2 model prediction thru onnx.</p><p>This code is not a best, not a beautiful.</p><p>But work.</p><h3>Preperation</h3><p>Before running code, you should prepare an environment.</p><p>I prefer pyenv anaconda3–5.0.1. When I used anaconda3–5.0.0, I failed to install onnxruntime.</p><pre>$ pyenv install anaconda3-5.0.1<br>$ pyenv local anaconda3-5.0.1<br>$ pip install onnxruntime</pre><p>If you want to install onnxruntime-gpu, you can modify the command.</p><p>And you have to download pretrained model of <a href="https://github.com/onnx/models/tree/master/tiny_yolov2">Tiny_YOLOv2 from onnx model zoo</a>.</p><pre>$ wget <a href="https://www.cntk.ai/OnnxModels/tiny_yolov2/opset_1/tiny_yolov2.tar.gz">https://www.cntk.ai/OnnxModels/tiny_yolov2/opset_1/tiny_yolov2.tar.gz</a><br>$ tar xvzf tiny_yolov2.tar.gz</pre><p>And you have to download some image file for inference. and rename to “test.jpg”</p><p>When you can running this example code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/416/1*n0JcI5qY-0RPA1oJquqwew.png" /></figure><pre>import numpy as np<br>import onnxruntime as rt<br>from PIL import Image,ImageDraw<br>sess = rt.InferenceSession(&quot;tiny_yolov2/model.onnx&quot;)<br>input_name = sess.get_inputs()[0].name</pre><pre>img = Image.open(&#39;test.jpg&#39;)<br>img = img.resize((416, 416)) #for tiny_yolov2</pre><pre>X = np.asarray(img)<br>X = X.transpose(2,0,1)<br>X = X.reshape(1,3,416,416)</pre><pre>out = sess.run(None, {input_name: X.astype(np.float32)})<br>out = out[0][0]</pre><pre>numClasses = 20<br>anchors = [1.08, 1.19, 3.42, 4.41, 6.63, 11.38, 9.42, 5.11, 16.62, 10.52]</pre><pre>def sigmoid(x, derivative=False):<br>  return x*(1-x) if derivative else 1/(1+np.exp(-x))</pre><pre>def softmax(x):<br>  scoreMatExp = np.exp(np.asarray(x))<br>  return scoreMatExp / scoreMatExp.sum(0)</pre><pre>clut = [(0,0,0),(255,0,0),(255,0,255),(0,0,255),(0,255,0),(0,255,128),<br>  (128,255,0),(128,128,0),(0,128,255),(128,0,128),<br>  (255,0,128),(128,0,255),(255,128,128),(128,255,128),(255,255,0),<br>  (255,128,128),(128,128,255),(255,128,128),(128,255,128)]<br>label = [&quot;aeroplane&quot;,&quot;bicycle&quot;,&quot;bird&quot;,&quot;boat&quot;,&quot;bottle&quot;,<br>         &quot;bus&quot;,&quot;car&quot;,&quot;cat&quot;,&quot;chair&quot;,&quot;cow&quot;,&quot;diningtable&quot;,<br>         &quot;dog&quot;,&quot;horse&quot;,&quot;motorbike&quot;,&quot;person&quot;,&quot;pottedplant&quot;,<br>          &quot;sheep&quot;,&quot;sofa&quot;,&quot;train&quot;,&quot;tvmonitor&quot;]</pre><pre>draw = ImageDraw.Draw(img)<br>for cy in range(0,13):<br> for cx in range(0,13):<br>  for b in range(0,5):<br>   channel = b*(numClasses+5)<br>   tx = out[channel  ][cy][cx]<br>   ty = out[channel+1][cy][cx]<br>   tw = out[channel+2][cy][cx]<br>   th = out[channel+3][cy][cx]<br>   tc = out[channel+4][cy][cx]</pre><pre>   x = (float(cx) + sigmoid(tx))*32<br>   y = (float(cy) + sigmoid(ty))*32<br>   <br>   w = np.exp(tw) * 32 * anchors[2*b  ]<br>   h = np.exp(th) * 32 * anchors[2*b+1] <br>   <br>   confidence = sigmoid(tc)</pre><pre>classes = np.zeros(numClasses)<br>   for c in range(0,numClasses):<br>    classes[c] = out[channel + 5 +c][cy][cx]<br>   classes = softmax(classes)<br>   detectedClass = classes.argmax()</pre><pre>if 0.5&lt; classes[detectedClass]*confidence:<br>    color =clut[detectedClass]<br>    x = x - w/2<br>    y = y - h/2<br>    draw.line((x  ,y  ,x+w,y ),fill=color)<br>    draw.line((x  ,y  ,x  ,y+h),fill=color)<br>    draw.line((x+w,y  ,x+w,y+h),fill=color)<br>    draw.line((x  ,y+h,x+w,y+h),fill=color)</pre><pre>img.save(&quot;result.png&quot;)</pre><h3>How it works?</h3><p>Basically, ONNX runtime needs create session object.<br>This case, we need only inference session. When you have to give a path of pretrained model.</p><pre>sess = rt.InferenceSession(&quot;tiny_yolov2/model.onnx&quot;)</pre><p>ONNX runtime needs a name of input tensor. So get it.</p><pre>input_name = sess.get_inputs()[0].name</pre><p>Okay, let’s read an image file and reshape.</p><pre>img = Image.open(&#39;test.jpg&#39;)<br>img = img.resize((416, 416)) #for tiny_yolov2</pre><pre>X = np.asarray(img)<br>X = X.transpose(2,0,1)<br>X = X.reshape(1,3,416,416)</pre><p>In the document of YOLO, input shape of this network is (1,3,416,416)</p><p>So I resize a image to (416,416).</p><p>The shape of np.asarray is (416,416,3). So we need to transpose shape to (2,0,1).</p><p>And then,the image data reshape to (1,3,416,416).When we ready to inferrence.</p><pre>out = sess.run(None, {input_name: X.astype(np.float32)})<br>out = out[0][0]</pre><p>Bravo, we solved a mystery of the secret parameter “X”.</p><p>It is a simple ndarray, but that type should be np.float32.</p><p>After that, we got a result of inference.</p><p>If you want to know about more, you should check out <a href="http://machinethink.net/blog/object-detection-with-yolo/">this article</a>.</p><p>Thank you for reading.</p><p>Ryo</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80828fcf71e1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>