我一直在玩,Deep Dream并Inceptionism使用Caffe框架来可视化层GoogLeNet,这是一个为Imagenet项目构建的架构,一个专为视觉对象识别而设计的大型可视化数据库.
Imagenet可以在这里找到:Imagenet 1000类.
为了探究架构并产生"梦想",我使用了三个笔记本:
https://github.com/kylemcdonald/deepdream/blob/master/dream.ipynb
https://github.com/auduno/deepdraw/blob/master/deepdraw.ipynb
这里的基本思想是从模型或"指南"图像中提取指定图层中每个通道的一些特征.
然后我们将我们希望修改的图像输入到模型中,并在指定的同一层中提取特征(对于每个八度音阶),增强最佳匹配特征,即两个特征向量的最大点积.
到目前为止,我已经设法使用以下方法修改输入图像和控制梦想:
- (a)将图层用作
'end'输入图像优化的目标.(见功能可视化)- (b)使用第二图像来指导输入图像上的de优化目标.
- (c)可视化
Googlenet由噪声产生的模型类.
但是,我想要实现的效果介于这些技术之间,我没有找到任何文档,论文或代码.
要使一个属于给定
'end'层的单个类或单元(a)引导优化目标(b)并使该类在输入图像上可视化(c):
一个例子,其中class = 'face'和input_image = 'clouds.jpg':
请注意:上面的图像是使用面部识别模型生成的,该模型未经过Imagenet数据集培训.仅用于演示目的.
方法(a)
from cStringIO import StringIO
import numpy as np
import scipy.ndimage as nd
import PIL.Image
from IPython.display import clear_output, Image, display
from google.protobuf …Run Code Online (Sandbox Code Playgroud) 我有一个真的很难试图安装在一个稳定的数据包的科学配置docker.使用这种主流的相关工具应该会更容易.
以下是曾经工作的Dockerfile,有点破解,从包核心中删除并单独安装,指定,因为据称,更高版本与之冲突.pandaspandas<0.21.0numpy
FROM alpine:3.6
ENV PACKAGES="\
dumb-init \
musl \
libc6-compat \
linux-headers \
build-base \
bash \
git \
ca-certificates \
freetype \
libgfortran \
libgcc \
libstdc++ \
openblas \
tcl \
tk \
libssl1.0 \
"
ENV PYTHON_PACKAGES="\
numpy \
matplotlib \
scipy \
scikit-learn \
nltk \
"
RUN apk add --no-cache --virtual build-dependencies python3 \
&& apk add --virtual build-runtime \
build-base python3-dev openblas-dev …Run Code Online (Sandbox Code Playgroud) 我知道还有另一个非常相似的问题,但我无法从中提取所需的信息.
我在(x,y)飞机上有4分:x=[x1,x2,x3,x4]和y=[y1,y2,y3,y4]
x=[-1 ,0.5 ,1,-0.5]
y=[ 0.5, 1, -0.5, -1]
Run Code Online (Sandbox Code Playgroud)
现在,我可以通过以下方式绘制四点:
import matplotlib.pyplot as plt
plt.plot(x,y, 'ro')
plt.axis('equal')
plt.show()
Run Code Online (Sandbox Code Playgroud)
但是,除了这四点,我想有两条线:
1)一个连接(x1,y1)带(x2,y2)和2)第二一个连接(x3,y3)带(x4,y4).
这是一个简单的玩具示例.在实际情况中,我在飞机上有2N点.
如何获得所需的输出:对于具有两条连接线的点?
谢谢.
一切都在与我的客户合作,直到我试图通过将我的客户服务从升级到,使用并再次构建它来解决一些网络断开连接的问题。react-scriptsdocker3.0.13.3.0npm install <package> --save
但后来它开始抱怨需要css-loader和style-loader,我安装了它们。然后它不起作用,我将我的设置恢复为3.0.1,卸载带有--save标志的以前的两个包,以便从中删除它node_modules/。
现在,当我运行时docker-compose -f docker-compose-dev.yml build client,虽然构建了客户端服务,但出现以下错误:
> fsevents@1.2.11 install /usr/src/app/node_modules/chokidar/node_modules/fsevents
> node-gyp rebuild
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@11.12.0 | linux | x64
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env …Run Code Online (Sandbox Code Playgroud) 有:
from twisted.internet import reactor
from scrapy.crawler import CrawlerProcess
Run Code Online (Sandbox Code Playgroud)
我总是成功地运行这个过程:
process = CrawlerProcess(get_project_settings())
process.crawl(*args)
# the script will block here until the crawling is finished
process.start()
Run Code Online (Sandbox Code Playgroud)
但是因为我已将此代码移动到web_crawler(self)函数中,如下所示:
def web_crawler(self):
# set up a crawler
process = CrawlerProcess(get_project_settings())
process.crawl(*args)
# the script will block here until the crawling is finished
process.start()
# (...)
return (result1, result2)
Run Code Online (Sandbox Code Playgroud)
并开始使用类实例化调用该方法,如:
def __call__(self):
results1 = test.web_crawler()[1]
results2 = test.web_crawler()[0]
Run Code Online (Sandbox Code Playgroud)
和运行:
test()
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Traceback (most recent call last):
File "test.py", line 573, in <module> …Run Code Online (Sandbox Code Playgroud) 我是React和Java语言的新手,如果这太基础了,请抱歉。
我有一个Menu组件,该组件呈现动画onClick,然后将应用程序重定向到另一条路线/coffee。
我想传递被单击(选择)的值以进行功能this.gotoCoffee和更新this.state.select,但我不知道如何进行操作,因为我正在this.state.coffees同一onClick事件中映射所有项目。
我该怎么做并更新this.state.select为点击值?
我的代码:
class Menus extends Component{
constructor (props) {
super(props);
this.state = {
coffees:[],
select: '',
isLoading: false,
redirect: false
};
};
gotoCoffee = () => {
this.setState({isLoading:true})
setTimeout(()=>{
this.setState({isLoading:false,redirect:true})
},5000)
}
renderCoffee = () => {
if (this.state.redirect) {
return (<Redirect to={`/coffee/${this.state.select}`} />)
}
}
render(){
const data = this.state.coffees;
return (
<div>
<h1 className="title is-1"><font color="#C86428">Menu</font></h1>
<hr/><br/>
{data.map(c =>
<span key={c}> …Run Code Online (Sandbox Code Playgroud) 背景 我想要压力传感器(他们正在工作)触发内置摄像头并在猫上床时拍照,上传图片并给我发电子邮件,以便我可以在网站上查看实时图像.
PHP服务器
我有一个php server running 127.0.0.1:8080这个结构的根:
NetworkedCat -->
data --> script-cat.php
index.html
NetworkedCat.pde
img.jpg
save2web.php
swiftmailer --> libs, etc
Run Code Online (Sandbox Code Playgroud)
在浏览器上进行测试,save2web.php并且cat-script.php正在运行,即脚本正在上传和通过电子邮件发送.
Arduino的
Arduino应用程序应执行以下操作:
压力传感器()也在读取和打印,并且已经校准了阈值.
但NetworkedCat.pde不是由串行事件触发的.
请注意:
Arduino Processinglocalhost在另一个开放port 80,因为php server工作8080.
如果我缩短处理代码,并测试图像捕获和上传,它就可以工作.所以,bug必须与串行事件有关.
为什么下面的处理代码不起作用?
/*Serial String reader
Context: Arduino
Reads in a string of characters until it gets a linefeed (ASCII 10).
then converts the string into a number
*/
import …Run Code Online (Sandbox Code Playgroud) 我试图安装一个特定Keras的版本Keras 1 API使用conda-forge,因为
$ conda search keras
仅返回以下Keras 2 API选项:
keras 2.0.8 py35h86bcf3e_0 defaults
2.0.8 py27h242e9fd_0 defaults
2.0.8 py36h39110e4_0 defaults
Run Code Online (Sandbox Code Playgroud)
而
$ conda search keras --channel conda-forge
除了通常的渠道外,返回更多选项,例如:
keras 2.0.8 py35h86bcf3e_0 defaults
2.0.8 py27h242e9fd_0 defaults
2.0.8 py36h39110e4_0 defaults
1.0.7 py27_0 conda-forge
1.0.7 py34_0 conda-forge
1.0.7 py35_0 conda-forge
1.0.7 py36_0 conda-forge
1.2.2 py27_0 conda-forge
1.2.2 py35_0 conda-forge
1.2.2 py36_0 conda-forge
2.0.0 py27_0 conda-forge
2.0.0 py35_0 conda-forge
2.0.0 py36_0 conda-forge
2.0.1 py27_0 conda-forge
2.0.1 …Run Code Online (Sandbox Code Playgroud) 在users,我正在尝试配置"docker-entrypoint-initdb.d",启动并在另一个容器中运行,并将其链接到我的entrypoint.sh服务,使用以下结构进行设置:
docker-compose-dev.yml
services/
users/
manage.py
Dockerfile-dev
entrypoint.sh
project/
__init__.py
config.py
db/
create.sql
Dockerfile
Run Code Online (Sandbox Code Playgroud)
搬运工-撰写-dev.yml
version: '3.7'
services:
users:
build:
context: ./services/users
dockerfile: Dockerfile-dev
volumes:
- './services/users:/usr/src/app'
ports:
- 5001:5000
environment:
- FLASK_APP=project/__init__.py
- FLASK_ENV=development
- APP_SETTINGS=project.config.DevelopmentConfig
- DATABASE_URL=postgres://postgres:postgres@users-db:5432/users_dev
- DATABASE_TEST_URL=postgres://postgres:postgres@users-db:5432/users_test
depends_on:
- users-db
users-db:
build:
context: ./services/users/project/db
dockerfile: Dockerfile
ports:
- 5435:5432
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
Run Code Online (Sandbox Code Playgroud)
Dockerfile-dev的
# base image
FROM python:3.7.2-alpine
# install dependencies
RUN apk update && \
apk add --virtual …Run Code Online (Sandbox Code Playgroud) 背景
我正在我的 React 应用程序中测试隐式流身份验证,并尝试实现所谓的 静默刷新功能,在用户登录时,我定期要求一个新的访问令牌,而无需要求他提供新的授权。
以下是 Flow 模式Auth0 Tenant,在我的例子中,是 Spotify:
虽然使用隐式授权的 SPA(单页应用程序)不能使用刷新令牌,但还有其他方法可以提供类似的功能:
prompt=none调用/authorize端点时使用。用户不会看到登录或同意对话框。
/authorize从隐藏的 iframe调用并从父框架中提取新的访问令牌。用户不会看到重定向发生。
另一种方法是实现类似包axios-auth-refresh 的东西,一个库
帮助您通过
axios拦截器实现授权的自动刷新。当原始请求失败时,您可以轻松拦截原始请求,刷新授权并继续原始请求,无需任何用户交互。
用法:
import axios from 'axios';
import createAuthRefreshInterceptor from 'axios-auth-refresh';
// Function that will be called to refresh authorization
const refreshAuthLogic = failedRequest => axios.post('https://www.example.com/auth/token/refresh').then(tokenRefreshResponse => {
localStorage.setItem('token', tokenRefreshResponse.data.token);
failedRequest.response.config.headers['Authorization'] = 'Bearer ' + tokenRefreshResponse.data.token;
return Promise.resolve();
});
// Instantiate the interceptor (you can chain it as …Run Code Online (Sandbox Code Playgroud) docker ×3
python ×3
reactjs ×2
alpine-linux ×1
arduino ×1
auth0 ×1
axios ×1
caffe ×1
conda ×1
conda-forge ×1
deep-dream ×1
imagenet ×1
install ×1
java ×1
javascript ×1
keras ×1
matplotlib ×1
node.js ×1
npm ×1
numpy ×1
pandas ×1
postgresql ×1
processing ×1
scrapy ×1
spotify ×1
web-crawler ×1