我有一个exports file包含所有续集模型的模型,然后定义模型之间的关系。它看起来像:
// Snippet from the global init file
for (let modelFile of modelFileList) {
// ... Some code ...
// Require the file
appliedModels[modelName] = require(`../${MODEL_DIR}/${modelFile}`).call(null, _mysql);
}
//Define the relationship between the sql models
_defineRelationship(appliedModels);
function _defineRelationship(models) {
models._planAllocationModel.belongsTo(models._subscriptionModel, {
foreignKey: 'subscription_id',
targetKey: 'subscription_id'
});
}
Run Code Online (Sandbox Code Playgroud)
但是当我尝试包含这样的模型时:
_subscriptionModel.findAll({
where: {
start_date: {
_lte: today // Get all subscriptions where start_date <= today
}
},
limit,
include: [
{
model: _planAllocationModel
}
]
});
Run Code Online (Sandbox Code Playgroud)
续集抛出错误:SequelizeEagerLoadingError: tbl_plan_allocation …
我试图使用HoughCircles检测下图中的圆圈.
这是我正在调整以找到所有圈子的代码.
import cv2
import numpy as np
img = cv2.imread("images/coins.jpg", 0)
cimg = cv2.cvtColor(img,cv2.COLOR_GRAY2BGR)
minDist = 247
circles = cv2.HoughCircles(img,cv2.HOUGH_GRADIENT,1,minDist,
param1=170,param2=80,minRadius=0,maxRadius=0)
print(circles)
#print("Number of circles detected ", circles.length)
circles = np.uint16(np.around(circles))
for i in circles[0,:]:
# draw the outer circle
cv2.circle(cimg,(i[0],i[1]),i[2],(0,255,0),2)
# draw the center of the circle
cv2.circle(cimg,(i[0],i[1]),2,(0,0,255),3)
cv2.imshow('detected circles',cimg)
cv2.waitKey(0)
cv2.destroyAllWindows()
Run Code Online (Sandbox Code Playgroud)
对于我尝试的一切,我无法检测到一枚硬币.检测到的圆圈如下所示.
我这里有三个问题:
minDist参数呢?你能解释一下它的工作原理吗?我阅读了文档,但无法理解.minRadius和maxRadius的zero平均值在这里?在检测圆圈之前,我正在用red通道替换green通道。替换通道后,我将其通过模糊过滤器,然后进行霍夫变换以检测圆圈。但是当我这样做时,我收到一条糟糕的错误消息:
OpenCV(3.4.1) Error: Assertion failed (!_image.empty() && _image.type() == (((0) & ((1 << 3) - 1)) + (((1)-1) << 3)) && (_image.isMat() ||
_image.isUMat())) in HoughCircles, file /io/opencv/modules/imgproc/src/hough.cpp, line 1659
Traceback (most recent call last):
File "circle_light.py", line 44, in <module>
param1=param1,param2=param2,minRadius=minRadius,maxRadius=maxRadius)
cv2.error: OpenCV(3.4.1) /io/opencv/modules/imgproc/src/hough.cpp:1659: error: (-215) !_image.empty()
&& _image.type() == (((0) & ((1 << 3) - 1)) + (((1)-1) << 3)) && (_image.isMat() || _image.isUMat()) in function HoughCircles
Run Code Online (Sandbox Code Playgroud)
我无法理解它,因此无法理解我可能做错了什么。这是我所做的事情的片段。
import cv2
img = cv2.imread("images/{}".format("img.png"), 1) …Run Code Online (Sandbox Code Playgroud) python opencv image-processing computer-vision hough-transform
我正在尝试了解 javascript 的Symbol.asyncIterator和await of。我写了一些简单的代码,它抛出一个错误说:
TypeError: undefined is not a function
Run Code Online (Sandbox Code Playgroud)
在尝试使用for await (let x of a).
我不明白这样做的原因。
let a = {}
function test() {
for(let i=0; i < 10; i++) {
if(i > 5) {
return Promise.resolve(`Greater than 5: (${i})`)
}else {
return Promise.resolve(`Less than 5: (${i})`)
}
}
}
a[Symbol.asyncIterator] = test;
async function main() {
for await (let x of a) { // LINE THAT THROWS AN ERROR
console.log(x)
}
}
main() …Run Code Online (Sandbox Code Playgroud) 我已经编写了一个基于antd上传的小组件,使用该组件用户可以将多个文件上传到服务器。我花了很多时间进行调试,但是无法理解其某些行为。该组件如下所示:
我面临两个问题:
prefil包含已经上载到服务器的文件的组件,我就无法添加新文件。当我尝试单击后上载新文件时Add Another,如下所示该组件将恢复到其最初具有2个文件的默认状态。我只是不知道该如何处理。
Add another。我知道在某个地方,我无法正确管理组件的状态,但是我无法弄清楚自己。这是使用打字稿编写的组件代码。
import { Button, Icon, Form, Input, Upload, message } from "antd";
export type DefaultFileList = {
uid: number | string;
name: string;
status?: string;
url: string;
fileLabel: string;
};
type state = {
uploadFieldIdContainer: number[];
mocAddErrorDescription?: string;
uploadMap: { [index: number]: UploadFile[] };
defaultMap: {
[index: number]: {
default: DefaultFileList[];
fileLabel: string;
};
};
};
type oprops = {
prefil: DefaultFileList[];
buttonLabel?: string;
type: …Run Code Online (Sandbox Code Playgroud) 我在Effective C++中遇到过这一行:
公共意味着未封装,实际上,未封装意味着不可更改,特别是对于广泛使用的类.广泛使用的类最需要封装,因为它们最能从更好地替换一个实现的能力中受益一
作者的意思是"公共意味着未被封装,实际上,未封装意味着不可改变"?
未封装的如何不可改变?
我无法将动作侦听器添加到树中的特定节点.这是我构建的一棵树:

我想为每个节点注册一个单独的监听器.现在我已经注册了一个听众JTree.所以,每当我点击tree监听器方法的任何部分开始它的工作.(即现在我有一个共同的倾听者)
我想要的是当我点击音频时,一个听众注册听到音频点击,应该开始它的工作,同样适用于视频.我怎样才能做到这一点 ?
这是我到目前为止的注册方式:
jTree1.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
public void valueChanged(javax.swing.event.TreeSelectionEvent evt) {
jTree1ValueChanged(evt);
}
});
public void jTree1ValueChanged( TreeSelectionEvent tse ) {...}
Run Code Online (Sandbox Code Playgroud) 会话持续多长时间:
HttpSession session = request.getSession();
Run Code Online (Sandbox Code Playgroud)
最后我没有明确申报session.setMaxInactiveInterval(int i)?我们假设,用户不会从浏览器中删除cookie.
当我运行以下代码时:
import java.util.LinkedList;
class Tester {
public static void main(String args[]) {
LinkedList<String> list = new LinkedList<String>();
list.add(new String("suhail"));
list.add(new String("gupta"));
list.add(new String("ghazal"));
list.add(new String("poetry"));
list.add(new String("music"));
list.add(new String("art"));
try {
for(String s : list) {
list.add(0,"art");
list.remove(6);
System.out.println(list);
}
}catch(Exception exc) {
exc.printStackTrace();
}
}
}
Run Code Online (Sandbox Code Playgroud)
我得到一个例外,说:
java.util.ConcurrentModificationException
at java.util.LinkedList$ListItr.checkForComodification(Unknown Source)
at java.util.LinkedList$ListItr.next(Unknown Source)
at Tester.main(Tester.java:14)
Run Code Online (Sandbox Code Playgroud)
为什么我得到这个例外?
编辑:tmpList是一个LinkedList,其每个节点都包含DepConfAttr类型的对象.我在内存(最高内存优先)的基础上对tmpList进行排序,这是DepConfAttr对象的属性之一.
上面的代码反映了我试图通过以下代码实现的目标
int size = tmpList.size();
int elementBC = 0; // element being checked
int startIndex = 1;
for (DepConfAttr dca : …Run Code Online (Sandbox Code Playgroud) 我试图理解函数中的epochs参数Doc2Vec和epochs函数中的参数train。
在以下代码片段中,我手动设置了4000次迭代的循环。是否需要或在Doc2Vec中传递4000作为纪元参数足够?另外epochsin Doc2Vec与时代in有train什么不同?
documents = Documents(train_set)
model = Doc2Vec(vector_size=100, dbow_words=1, dm=0, epochs=4000, window=5,
seed=1337, min_count=5, workers=4, alpha=0.001, min_alpha=0.025)
model.build_vocab(documents)
for epoch in range(model.epochs):
print("epoch "+str(epoch))
model.train(documents, total_examples=total_length, epochs=1)
ckpnt = model_name+"_epoch_"+str(epoch)
model.save(ckpnt)
print("Saving {}".format(ckpnt))
Run Code Online (Sandbox Code Playgroud)
此外,权重如何以及何时更新?