<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>AI &#8211; 天地一沙鸥</title>
	<atom:link href="https://haoluobo.com/tag/ai/feed/" rel="self" type="application/rss+xml" />
	<link>https://haoluobo.com</link>
	<description>to be continue....</description>
	<lastBuildDate>Fri, 28 Apr 2023 03:11:55 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>
	<item>
		<title>一个AI公司需要多少人</title>
		<link>https://haoluobo.com/2023/04/how-many-people-do-you-need-for-an-ai-company/</link>
					<comments>https://haoluobo.com/2023/04/how-many-people-do-you-need-for-an-ai-company/#respond</comments>
		
		<dc:creator><![CDATA[vicalloy]]></dc:creator>
		<pubDate>Thu, 27 Apr 2023 09:29:42 +0000</pubDate>
				<category><![CDATA[编程]]></category>
		<category><![CDATA[AI]]></category>
		<category><![CDATA[Midjourney]]></category>
		<category><![CDATA[OpenAI]]></category>
		<guid isPermaLink="false">https://haoluobo.com/?p=12402</guid>

					<description><![CDATA[Stable Diffusion 和 ChatGPT 的大火，让沉寂已久的AI世界再次翻红。又开始有人在问，在 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p><code>Stable Diffusion</code> 和 <code>ChatGPT</code> 的大火，让沉寂已久的AI世界再次翻红。又开始有人在问，在AI越来越成熟的今天，程序员是否有必要去学算法，投身AI行业。在我看来对程序员而言AI带来的机会更多是如何利用AI带来的能力而不是去创造一个AI。</p>



<p>曾在AI公司待过一段时间，这段经历给我最大的感觉是： AI 行业是一个资本密集型产业，对普通程序员来说没太多的机会。AI的发展对普通程序员带来的最大变化是出现来一批很好用的 API ，可以实现一些以前实现不了的想法。另外就是如何利用新出现的一批AI工具提高自己的工作效率。</p>



<h2 class="wp-block-heading">为什么不建议普通程序员进入AI行业</h2>



<p>简单来说AI行业需要的专业算法人员非常少，且门槛非常高。非算法相关的人员，相对而言门槛又太低。</p>



<ol class="wp-block-list">
<li>常规应用，通用模型已经很成熟了。对于 99.9%人根本不可能构建出一个比开源模型更好的模型。</li>



<li>模型的性能优化是个体力活，而且随着技术的发展，以后可能不需要手动的性能优化。</li>



<li>模型的调优需要大量的数据和硬件。数据清洗是和 AI 没关系的纯体力活。参数调优又需要大量的硬件，¥成本普通人（公司）根本承担不起（据说 ChatGPT 训练一次的成本就高达 1 千万美元）。</li>
</ol>



<h2 class="wp-block-heading">一个AI公司需要多少人</h2>



<p>前面说到AI公司需要的人少，但具体少到什么程度可能会超乎很多人的想象。</p>



<h3 class="wp-block-heading">OpenAI</h3>



<p><code>OpenAI</code>（<code>ChatGPT</code> 的母公司），仅2022年，就花费了约5.44亿美元。而与之对应的是”今年1月，OpenAI创始人透露公司员工人数为375人“。关键是这375人里包含了行政等支持人员及数据收集整理人员。</p>



<h2 class="wp-block-heading">Midjourney</h2>



<p>相比 <code>OpenAI</code> ，AI绘图领域的巨头 <code>Midjourney</code> 在人力方面更是做到了极致。<code>Midjourney</code> 总共只有11人：1创始人，1财务，1法务，8研发（其中4人为本科实习生）。</p>



<h2 class="wp-block-heading">参考</h2>



<ul class="wp-block-list">
<li><a href="https://wallstreetcn.com/articles/3687460" target="_blank" rel="noreferrer noopener">Midjourney：伟大的公司只需要十一人</a></li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://haoluobo.com/2023/04/how-many-people-do-you-need-for-an-ai-company/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>使用AI修复将画像还原成照片</title>
		<link>https://haoluobo.com/2023/01/art-face-to-photo/</link>
					<comments>https://haoluobo.com/2023/01/art-face-to-photo/#respond</comments>
		
		<dc:creator><![CDATA[vicalloy]]></dc:creator>
		<pubDate>Mon, 16 Jan 2023 13:23:00 +0000</pubDate>
				<category><![CDATA[vicalloy的庄家]]></category>
		<category><![CDATA[AI]]></category>
		<category><![CDATA[GFPGAN]]></category>
		<guid isPermaLink="false">https://haoluobo.com/?p=12366</guid>

					<description><![CDATA[GFPGAN 是一个使用 AI 进行人脸修复的工具，即使对非常模糊的人脸也可起到不错的修复效果。Hugging [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p><a rel="noreferrer noopener" href="https://github.com/TencentARC/GFPGAN" data-type="URL" data-id="https://github.com/TencentARC/GFPGAN" target="_blank">GFPGAN</a> 是一个使用 AI 进行人脸修复的工具，即使对非常模糊的人脸也可起到不错的修复效果。<a rel="noreferrer noopener" href="https://huggingface.co/" data-type="URL" data-id="https://huggingface.co/" target="_blank">Hugging Face</a> 提供了AI应用Demo的快速部署。我 Fork 了一份 GFPGAN 的 Demo 并做了少量的调整以加强对图片的支持。</p>



<p><strong>在线体验地址</strong> <a href="https://huggingface.co/spaces/vicalloy/GFPGAN">https://huggingface.co/spaces/vicalloy/GFPGAN</a></p>



<p>AI技术在图片生成领域有了不错的进展，现在已经可以通过文字生成质量不错的图片了。之前就一直想尝试用AI人脸修复将画中的人脸修复成照片，只是迫于拖延症一直未能真正动手。这些天试了一下，发现这个想法切实可行，就是修复出的效果算不上出色。</p>



<h3 class="wp-block-heading">Tips</h3>



<ol class="wp-block-list">
<li>AI 照片修复实际上是让 AI 对图片进行自行“脑补”的一个过程，所以原图细节一定不能过多（图片一定要小，或是），不然不利于 AI 软件的自行发挥。</li>



<li>樱木花道的输出效果不太好，再小丢失的细节又过多，因此加了个高斯模糊。注：理论上加高斯模糊比单纯的缩小图片效果要好，大家可以对其他图片试试。</li>



<li>应当是缺少样本，外加人脸检测时，如果胡子过长截取人脸时会丢失部分胡子。古人的长须无法完整修复。</li>



<li>过于“漫画化”的图片是无法识别到人脸的。</li>
</ol>



<h3 class="wp-block-heading">效果</h3>



<p>樱木花道</p>



<figure class="wp-block-image size-full"><img decoding="async" width="194" height="212" src="https://haoluobo.com/wp-content/uploads/2023/01/樱木花道.jpg" alt="" class="wp-image-12361"/></figure>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="776" height="848" src="https://haoluobo.com/wp-content/uploads/2023/01/樱木花道out.jpg" alt="" class="wp-image-12363" srcset="https://haoluobo.com/wp-content/uploads/2023/01/樱木花道out.jpg 776w, https://haoluobo.com/wp-content/uploads/2023/01/樱木花道out-275x300.jpg 275w, https://haoluobo.com/wp-content/uploads/2023/01/樱木花道out-768x839.jpg 768w, https://haoluobo.com/wp-content/uploads/2023/01/樱木花道out-624x682.jpg 624w" sizes="(max-width: 776px) 100vw, 776px" /></figure>



<p>唐太宗李世民</p>



<figure class="wp-block-image size-full"><img decoding="async" width="80" height="107" src="https://haoluobo.com/wp-content/uploads/2023/01/李世民.jpg" alt="" class="wp-image-12359"/></figure>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="320" height="428" src="https://haoluobo.com/wp-content/uploads/2023/01/李世民out.jpg" alt="" class="wp-image-12360" srcset="https://haoluobo.com/wp-content/uploads/2023/01/李世民out.jpg 320w, https://haoluobo.com/wp-content/uploads/2023/01/李世民out-224x300.jpg 224w" sizes="auto, (max-width: 320px) 100vw, 320px" /></figure>



<p>乾隆</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="192" height="180" src="https://haoluobo.com/wp-content/uploads/2023/01/乾隆.jpg" alt="" class="wp-image-12357"/></figure>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="768" height="720" src="https://haoluobo.com/wp-content/uploads/2023/01/乾隆out.jpg" alt="" class="wp-image-12358" srcset="https://haoluobo.com/wp-content/uploads/2023/01/乾隆out.jpg 768w, https://haoluobo.com/wp-content/uploads/2023/01/乾隆out-300x281.jpg 300w, https://haoluobo.com/wp-content/uploads/2023/01/乾隆out-624x585.jpg 624w" sizes="auto, (max-width: 768px) 100vw, 768px" /></figure>



<p>韩熙载</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="110" height="266" src="https://haoluobo.com/wp-content/uploads/2023/01/韩熙载.jpg" alt="" class="wp-image-12364"/></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="423" height="1024" src="https://haoluobo.com/wp-content/uploads/2023/01/韩熙载out-423x1024.jpg" alt="" class="wp-image-12365" srcset="https://haoluobo.com/wp-content/uploads/2023/01/韩熙载out-423x1024.jpg 423w, https://haoluobo.com/wp-content/uploads/2023/01/韩熙载out-124x300.jpg 124w, https://haoluobo.com/wp-content/uploads/2023/01/韩熙载out.jpg 440w" sizes="auto, (max-width: 423px) 100vw, 423px" /></figure>



<p>宋太祖赵匡胤</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="640" height="689" src="https://haoluobo.com/wp-content/uploads/2023/01/宋太祖.jpg" alt="" class="wp-image-12367" srcset="https://haoluobo.com/wp-content/uploads/2023/01/宋太祖.jpg 640w, https://haoluobo.com/wp-content/uploads/2023/01/宋太祖-279x300.jpg 279w, https://haoluobo.com/wp-content/uploads/2023/01/宋太祖-624x672.jpg 624w" sizes="auto, (max-width: 640px) 100vw, 640px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="951" height="1024" src="https://haoluobo.com/wp-content/uploads/2023/01/宋太祖out-951x1024.jpg" alt="" class="wp-image-12368" srcset="https://haoluobo.com/wp-content/uploads/2023/01/宋太祖out-951x1024.jpg 951w, https://haoluobo.com/wp-content/uploads/2023/01/宋太祖out-279x300.jpg 279w, https://haoluobo.com/wp-content/uploads/2023/01/宋太祖out-768x827.jpg 768w, https://haoluobo.com/wp-content/uploads/2023/01/宋太祖out-624x672.jpg 624w, https://haoluobo.com/wp-content/uploads/2023/01/宋太祖out.jpg 1280w" sizes="auto, (max-width: 951px) 100vw, 951px" /></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://haoluobo.com/2023/01/art-face-to-photo/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>将OpenVINO预训练模型转为为ONNX，并使用TVM进行优化</title>
		<link>https://haoluobo.com/2021/04/openvino-onnx-tvm/</link>
					<comments>https://haoluobo.com/2021/04/openvino-onnx-tvm/#respond</comments>
		
		<dc:creator><![CDATA[vicalloy]]></dc:creator>
		<pubDate>Thu, 22 Apr 2021 13:17:21 +0000</pubDate>
				<category><![CDATA[编程]]></category>
		<category><![CDATA[AI]]></category>
		<category><![CDATA[ONNX]]></category>
		<category><![CDATA[OpenVINO]]></category>
		<category><![CDATA[TVM]]></category>
		<guid isPermaLink="false">/?p=11868</guid>

					<description><![CDATA[OpenVINO是Intel推出的一款深度学习工具套件。OpenVINO带来大量的预训练模型，使用这些预训练模 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>OpenVINO是Intel推出的一款深度学习工具套件。OpenVINO带来大量的预训练模型，使用这些预训练模型可以快速的开发出自己的AI应用。</p>



<p>不过既然是Intel出的东西，自然少不了和Intel平台深度绑定。OpenVINO主要针对Intel的CPU进行优化。虽然也可以支持GPU，但支持的是Intel家的GPU。Intel家的GPU，应当不用报太多期待了。</p>



<p>为了支持更丰富的硬件类型，可以将OpenVINO自带的预训练模型 转为ONNX格式，然后在做其他处理。</p>



<h2 class="wp-block-heading">OpenVINO模型导出为ONNX</h2>



<p>OpenVINO优化后的预训练模型无法直接转换为ONNX。不过好在Intel有提供模型的训练和导出工具，利用OpenVINO的训练工具导出ONNX</p>



<p>OpenVINO用于训练和导出的库为： <a href="https://github.com/openvinotoolkit/training_extensions" target="_blank" rel="noreferrer noopener">https://github.com/openvinotoolkit/training_extensions</a> 。</p>



<p>具体的操作方式参见项目的具体说明文档。</p>



<p>对照人脸检测的文档，导出人脸检测对应ONNX模型： <a href="https://github.com/openvinotoolkit/training_extensions/tree/develop/models/object_detection/model_templates/face-detection" target="_blank" rel="noreferrer noopener">https://github.com/openvinotoolkit/training_extensions/tree/develop/models/object_detection/model_templates/face-detection</a></p>



<p>注：导出目录里有 <code>export/</code>，<code>export/alt_ssd_export/</code> 两种模型。其中 <code>export/alt_ssd_export/</code> 包含了OpenVINO特有的实现，在转换为其他推理引擎模型时会失败，因此后续工作使用 <code>export/</code> 中的模型。</p>



<h2 class="wp-block-heading">使用TVM对ONNX模型进行优化</h2>



<h3 class="wp-block-heading">针对TVM的VM进行优化</h3>



<p>对于存在动态shape的模型，TVM无法进行编译。很不幸的是OpenVINO中物体检测相关的模型都存在动态shape。在TVM无法编译的情况下，可使用TVM的VM进行执行。</p>



<ul class="wp-block-list"><li>注：<ul><li>关于VM的相关内容请阅读： <a href="https://tvm.apache.org/docs/dev/virtual_machine.html" target="_blank" rel="noreferrer noopener">https://tvm.apache.org/docs/dev/virtual_machine.html</a></li><li>TVM的文档比较欠缺（特别是VM相关的内容）。不过好在项目还在快速迭代过程中，提交的issue很快就可以得到回复。</li><li>根据测试，使用VM模式，在CPU上TVM的速度甚至比用 <code>ONNXRuntime</code> 还要慢不少。不知道是否是跑在虚拟机上的关系。</li></ul></li></ul>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
import onnx
import time
import tvm
import numpy as np
import tvm.relay as relay
target = &#039;llvm -mcpu=skylake&#039;
model_path = &#039;face-detection-0200.onnx&#039;
onnx_model = onnx.load(model_path)
shape = &#x5B;1,3,256,256]
input_name = &quot;image&quot;
shape_dict = {
        input_name: shape,
        }
mod, params = relay.frontend.from_onnx(onnx_model, shape_dict)
print(relay.transform.DynamicToStatic()(mod))
with tvm.transform.PassContext(opt_level=3):
    executable = relay.vm.compile(mod, target=&quot;llvm&quot;, target_host=None, params=params)
code, lib = executable.save()
with open(&quot;code.ro&quot;, &quot;wb&quot;) as fo:
    fo.write(code)
lib.export_library(&quot;lib.so&quot;)
</pre></div>


<h3 class="wp-block-heading">针对TVM进行编译和优化</h3>



<p>如果你的模型可以正常编译，那就没必要采用VM模式了。直接编译理论上优化效果要好很多。这里采用的是TVM范例中给出的图片分类模型。</p>



<p>一个完整的模型优化和执行可以参考官方文档：<a href="https://tvm.apache.org/docs/tutorials/get_started/auto_tuning_with_python.html#sphx-glr-tutorials-get-started-auto-tuning-with-python-py" data-type="URL" data-id="https://tvm.apache.org/docs/tutorials/get_started/auto_tuning_with_python.html#sphx-glr-tutorials-get-started-auto-tuning-with-python-py" target="_blank" rel="noreferrer noopener">Compiling and Optimizing a Model with the Python AutoScheduler</a></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
import onnx
import time
import tvm
import numpy as np
import tvm.relay as relay
target = &#039;llvm&#039;
model_name = &#039;mobilenetv2&#039;
model_path = f&#039;{model_name}.onnx&#039;
onnx_model = onnx.load(model_path)
mod, params = relay.frontend.from_onnx(onnx_model)
with relay.build_config(opt_level=3):
    graph, lib, params = relay.build(mod, target, params=params)
path_lib = f&quot;./{model_name}.so&quot;
lib.export_library(path_lib)
fo=open(f&quot;./{model_name}.json&quot;,&quot;w&quot;)
fo.write(graph)
fo.close()
fo=open(&quot;./{model_name}.params&quot;,&quot;wb&quot;)
fo.write(relay.save_param_dict(params))
fo.close()
</pre></div>


<h3 class="wp-block-heading">VM模式下加载和运行优化好的模型</h3>



<p>加载前面导出的模型，并执行。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">

import onnx
import time
import tvm
import numpy as np
import tvm.relay as relay
def vmobj_to_array(o, dtype=np.float32):
    if isinstance(o, tvm.nd.NDArray):
        return &#x5B;o.asnumpy()]
    elif isinstance(o, tvm.runtime.container.ADT):
        result = &#x5B;]
        for f in o:
            result.extend(vmobj_to_array(f, dtype))
        return result
    else:
        raise RuntimeError(&quot;Unknown object type: %s&quot; % type(o))
shape = &#x5B;1, 3, 224, 224]
model_path = &#039;face-detection-0200&#039;
loaded_lib = tvm.runtime.load_module(f&quot;{model_path}.tvm.so&quot;)
loaded_code = bytearray(open(f&quot;{model_path}.tvm.code&quot;, &quot;rb&quot;).read())
exe = tvm.runtime.vm.Executable.load_exec(loaded_code, loaded_lib)
ctx = tvm.cpu()
vm = tvm.runtime.vm.VirtualMachine(exe, ctx)
data = np.random.uniform(size=shape).astype(&quot;float32&quot;)
out = vm.run(data)
out = vmobj_to_array(out)
print(out)
</pre></div>]]></content:encoded>
					
					<wfw:commentRss>https://haoluobo.com/2021/04/openvino-onnx-tvm/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
