Tag Archives: label

[Solved] yolo Error: IndexError: invalid index to scalar variable.

code:

yolo_layers = [layers[i[0] - 1] for i in network.getUnconnectedOutLayers()]

report errors:

Traceback (most recent call last):
  File "Run.py", line 201, in <module>
    main()
  File "Run.py", line 137, in main
    detections = yolo.detect(yolo_img)
  File "code/3D-BoundingBox-master/yolo/yolo.py", line 34, in detect
    ln = [ln[i[0] - 1] for i in self.net.getUnconnectedOutLayers()]
  File "code/3D-BoundingBox-master/yolo/yolo.py", line 34, in <listcomp>
    ln = [ln[i[0] - 1] for i in self.net.getUnconnectedOutLayers()]
IndexError: invalid index to scalar variable.

Reason:
different opencv versions cause different output formats

Solution:

yolo_layers = [layers[i - 1] for i in network.getUnconnectedOutLayers()]

Reference:
https://stackoverflow.com/questions/69834335/loading-yolo-invalid-index-to-scalar-variable

[Mac Pro M1] Python3.9 import cv2 Error: Reason: image not found

If you forget to copy the original error message, the content is similar to:

>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File 
"/Users/xxx/Anaconda/anaconda/envs/python35/lib/python3.5/site-packages/cv2/__init__.py", line 4, in <module>
    from .cv2 import *
ImportError: dlopen(/Users/xxx/Anaconda/anaconda/envs/python35/lib/python3.5/site-packages/cv2/cv2.cpython-35m-darwin.so, 2): Library not loaded: /System/Library/Frameworks/CoreImage.framework/Versions/A/CoreImage
  Referenced from: /Users/xxx/Anaconda/anaconda/envs/python35/lib/python3.5/site-packages/cv2/.dylibs/libavcodec.57.107.100.dylib
  Reason: image not found
>>> `

The breakthrough is also in the error report, which indicates that the libavcodec library may be missing or have problems. The solution is to install the library

Specific:

$ brew install libav
$ brew install ffmpeg

404 solution for WordPress Chinese tag

One of the common problems in blogs or websites built by WordPress is that the Chinese tag link does not exist. Google Administrator Tool prompt grabs 404 errors. In particular, windows hosts often have Chinese tag link grabbing errors, and Chinese tags cannot be displayed normally. Or Chinese tags can be displayed normally, but 404 errors will appear after clicking the link, which brings great inconvenience to users and is extremely difficult It greatly reduces the friendliness of the website.

How to solve this problem?

First method:

Open WP include/ classes.php (before 3.1) or WP include/class- wp.php (after 3.1 +, hereinafter referred to as the new version) find line 154 (the new version is line 142)

$pathinfo = $_ SERVER['PATH_ INFO';

Replace with:

$pathinfo = mb_ convert_ encoding($_ SERVER['PATH_ INFO'], 'UTF-8', 'GBK');

Find line 159 (the new version is line 147)

$req_ uri = $_ SERVER['REQUEST_ URI'];

Replace with:

$req_ uri = mb_ convert_ encoding($_ SERVER['REQUEST_ URI'], 'UTF-8', 'GBK');

After my personal test, this method can be used, the new version of the statement may be different from the above, but the method is basically the same, the corresponding statement can be replaced.

Second method:

1. Found in the WP includes folder at the root of the site“ rewrite.php ”This document;

2. Back it up“ rewrite.php ”In case of error (we’d better back up the original code before changing the code);

3. Open“ rewrite.php ”We find the following code in the file:

function get_tag_permastruct()
{
   if (isset($this-&gt;tag_structure)) 
  {
    return $this-&gt;tag_structure;
  }
  if (empty($this-&gt;permalink_structure)) 
  { 
    //Change this line
    $this-&gt;tag_structure = '';
    return false;
  }
  if (empty($this-&gt;tag_base))
  $this-&gt;tag_structure = $this-&gt;front . 'tag/';
  else$this-&gt;tag_structure = $this-&gt;tag_base . '/';
  $this-&gt;tag_structure .= '%tag%';
  return $this-&gt;tag_structure;
}

4. Put some of them together

" if (empty($this-&gt;permalink_structure)) { ”

Amend to read

“ if (! empty($this-&gt;permalink_structure)) { ";

Note that there is only a “!” sign in English. After testing, this method is very effective. PS. didn’t find the code in this file directly…

The third method: the final solution to the Chinese tag 404 error is actually ISAPI_ Rewrite pseudo static rules are not well written, which leads to the failure to find the web page file. In fact, just change the rules: the previous tag pseudo static rules

RewriteRule /tag/(.*)$ /index\.php\?tag=$1

Changed rules

RewriteRule /tag/(.*)/$ /index\.php\?tag=$1

I didn’t test this method, so I can’t guarantee its availability. Please back it up before modification!

Third method:

If the above two methods are not feasible, we recommend another method: alias each tag.

Alias is another URL friendly name. It is usually lowercase and can only contain letters, numbers and hyphens.

But for blogs with more than 100 Chinese tags, this method has a huge workload. Use with caution.

This method can link English tags normally, but it works for websites with Chinese tag problems, but it doesn’t work for websites with 404 English tag links.

With root cause solution

Phenomenon: 1. There is no exception when the project starts, when the page is loaded into the spring:message In the background, the null pointer is abnormal, and the console will display the prompt with root cause;

2. Note out spring:message After related tags, there is no exception, but where the specific content should be displayed, the code value in the tag is displayed;

3. The same project can be used on other people’s computers, but not on my computer;

4. Available on eclipse, not on MyEclipse;

Reason: there is a space in the Tomcat installation path;

Solution: put the Tomcat of the deployment project in a path without spaces, such as the root directory.

The above are the phenomena and solutions I encountered. If there are any other phenomena and solutions, please add.