'2021/05/21'에 해당되는 글 4건

  1. 2021.05.21 Stopped (tty input)
  2. 2021.05.21 tflite common.h
  3. 2021.05.21 rpi 4b 해상도, 주사율 2
  4. 2021.05.21 라즈베리 파이 이미지 dd로 굽기
Linux API/linux2021. 5. 21. 17:33

stdin을 통해 입력을 받아 작동하는 프로그램을 쉘에서 실행하고 백드라운드로 돌리니 멈춘다?!

bg
[1] /test
#
[1]+  Stopped (tty input)        /test

 

[링크 : https://topic.alibabacloud.com/...-stopped-tty-input_1_16_30150438.html]

[링크 : https://unix.stackexchange.com/questions/294471/backgrounded-job-keeps-stopping]

 

아무튼 SIGTTIN이 들어와서 그렇다고 하는데

간단하게는.. 해당 시그널을 무시하면 되는거고..

다른 방법은 좀 더 고민해 봐야 할 듯 -_-

 

void
init_shell ()
{

  /* See if we are running interactively.  */
  shell_terminal = STDIN_FILENO;
  shell_is_interactive = isatty (shell_terminal);

  if (shell_is_interactive)
    {
      /* Loop until we are in the foreground.  */
      while (tcgetpgrp (shell_terminal) != (shell_pgid = getpgrp ()))
        kill (- shell_pgid, SIGTTIN);

      /* Ignore interactive and job-control signals.  */
      signal (SIGINT, SIG_IGN);
      signal (SIGQUIT, SIG_IGN);
      signal (SIGTSTP, SIG_IGN);
      signal (SIGTTIN, SIG_IGN);
      signal (SIGTTOU, SIG_IGN);
      signal (SIGCHLD, SIG_IGN);

      /* Put ourselves in our own process group.  */
      shell_pgid = getpid ();
      if (setpgid (shell_pgid, shell_pgid) < 0)
        {
          perror ("Couldn't put the shell in its own process group");
          exit (1);
        }

      /* Grab control of the terminal.  */
      tcsetpgrp (shell_terminal, shell_pgid);

      /* Save default terminal attributes for shell.  */
      tcgetattr (shell_terminal, &shell_tmodes);
    }
}

[링크 : https://www.gnu.org/software/libc/manual/html_node/Initializing-the-Shell.html]

 

Macro: int SIGTTINA process cannot read from the user’s terminal while it is running as a background job. When any process in a background job tries to read from the terminal, all of the processes in the job are sent a SIGTTIN signal. The default action for this signal is to stop the process. For more information about how this interacts with the terminal driver, see Access to the Terminal.

[링크 : https://www.gnu.org/software/libc/manual/html_node/Job-Control-Signals.html]

'Linux API > linux' 카테고리의 다른 글

select, poll, epoll  (0) 2021.11.02
Unhandled fault: external abort on non-linefetch  (0) 2021.05.25
linux gpio interrupt poll?  (0) 2021.05.04
Floating point exception  (0) 2021.04.05
실행파일 not fount, FATAL: kernel too old  (0) 2021.04.05
Posted by 구차니

label_image 예제를 보면 get_top_n 에서

(prediction[i] + 128) / 256.0 나 prediction[i] / 255.0 

같은 quantization 범위에 맞춘 무언가가 보이는데 

TfLiteQuantizationParams.scale 와 TfLiteQuantizationParams.zero_point을 이용하면 자동화 가능할 느낌.

template <class T>
void get_top_n(T* prediction, int prediction_size, size_t num_results,
               float threshold, std::vector<std::pair<float, int>>* top_results,
               TfLiteType input_type) {
  // Will contain top N results in ascending order.
  std::priority_queue<std::pair<float, int>, std::vector<std::pair<float, int>>,
                      std::greater<std::pair<float, int>>>
      top_result_pq;

  const long count = prediction_size;  // NOLINT(runtime/int)
  float value = 0.0;

  for (int i = 0; i < count; ++i) {
    switch (input_type) {
      case kTfLiteFloat32:
        value = prediction[i];
        break;
      case kTfLiteInt8:
        value = (prediction[i] + 128) / 256.0;
        break;
      case kTfLiteUInt8:
        value = prediction[i] / 255.0;
        break;
      default:
        break;
    }
    // Only add it if it beats the threshold and has a chance at being in
    // the top N.
    if (value < threshold) {
      continue;
    }

    top_result_pq.push(std::pair<float, int>(value, i));

    // If at capacity, kick the smallest value out.
    if (top_result_pq.size() > num_results) {
      top_result_pq.pop();
    }
  }

  // Copy to output vector and reverse into descending order.
  while (!top_result_pq.empty()) {
    top_results->push_back(top_result_pq.top());
    top_result_pq.pop();
  }
  std::reverse(top_results->begin(), top_results->end());
}

 

netron 에서 보면 quantization 범위가 나오는데, 어딘가 저장하고는 있는 듯 해서 검색 중

// SupportedQuantizationTypes.
typedef enum TfLiteQuantizationType {
  // No quantization.
  kTfLiteNoQuantization = 0,
  // Affine quantization (with support for per-channel quantization).
  // Corresponds to TfLiteAffineQuantization.
  kTfLiteAffineQuantization = 1,
} TfLiteQuantizationType;

// Structure specifying the quantization used by the tensor, if-any.
typedef struct TfLiteQuantization {
  // The type of quantization held by params.
  TfLiteQuantizationType type;
  // Holds a reference to one of the quantization param structures specified
  // below.
  void* params;
} TfLiteQuantization;

// Legacy. Will be deprecated in favor of TfLiteAffineQuantization.
// If per-layer quantization is specified this field will still be populated in
// addition to TfLiteAffineQuantization.
// Parameters for asymmetric quantization. Quantized values can be converted
// back to float using:
//     real_value = scale * (quantized_value - zero_point)
typedef struct TfLiteQuantizationParams {
  float scale;
  int32_t zero_point;
} TfLiteQuantizationParams;

// Parameters for asymmetric quantization across a dimension (i.e per output
// channel quantization).
// quantized_dimension specifies which dimension the scales and zero_points
// correspond to.
// For a particular value in quantized_dimension, quantized values can be
// converted back to float using:
//     real_value = scale * (quantized_value - zero_point)
typedef struct TfLiteAffineQuantization {
  TfLiteFloatArray* scale;
  TfLiteIntArray* zero_point;
  int32_t quantized_dimension;
} TfLiteAffineQuantization;

typedef struct TfLiteTensor {
  TfLiteType type;
  TfLitePtrUnion data;
  TfLiteIntArray* dims;
  TfLiteQuantizationParams params;
  TfLiteAllocationType allocation_type;
  size_t bytes;
  const void* allocation;
  const char* name;
  struct TfLiteDelegate* delegate;
  TfLiteBufferHandle buffer_handle;
  bool data_is_stale;
  bool is_variable;
  TfLiteQuantization quantization;
  TfLiteSparsity* sparsity;
  const TfLiteIntArray* dims_signature;
} TfLiteTensor;

 

+

2021.05.26

typedef struct TfLiteIntArray {
  int size;
// gcc 6.1+ have a bug where flexible members aren't properly handled
// https://github.com/google/re2/commit/b94b7cd42e9f02673cd748c1ac1d16db4052514c
#if (!defined(__clang__) && defined(__GNUC__) && __GNUC__ == 6 && \
     __GNUC_MINOR__ >= 1) ||                                      \
    defined(HEXAGON) || (__clang_major__ == 7 && __clang_minor__ == 1)
  int data[0];
#else
  int data[];
#endif
} TfLiteIntArray;

// Fixed size list of floats. Used for per-channel quantization.
typedef struct TfLiteFloatArray {
  int size;
// gcc 6.1+ have a bug where flexible members aren't properly handled
// https://github.com/google/re2/commit/b94b7cd42e9f02673cd748c1ac1d16db4052514c
// This also applies to the toolchain used for Qualcomm Hexagon DSPs.
#if !defined(__clang__) && defined(__GNUC__) && __GNUC__ == 6 && \
    __GNUC_MINOR__ >= 1
  float data[0];
#else
  float data[];
#endif
} TfLiteFloatArray;

 

class Interpreter {
  /// Invoke the interpreter (run the whole graph in dependency order).
  ///
  /// NOTE: It is possible that the interpreter is not in a ready state
  /// to evaluate (i.e. if a ResizeTensor() has been performed without an
  /// AllocateTensors().
  /// Returns status of success or failure.
  TfLiteStatus Invoke();

  /// WARNING: Experimental interface, subject to change
  Subgraph& primary_subgraph() {
    return *subgraphs_.front();  /// Safe as subgraphs_ always has 1 entry.
  }
  
  /// Read only access to list of inputs.
  const std::vector<int>& inputs() const { return primary_subgraph().inputs(); }
  
  /// Read only access to list of outputs.
  const std::vector<int>& outputs() const {
    return primary_subgraph().outputs();
  }
  
  // Subgraphs
  std::vector<std::unique_ptr<Subgraph>> subgraphs_;
};

[링크 : https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/interpreter.h]

 

class Subgraph {
  // Array of indices representing the tensors that are inputs to the
  // interpreter.
  std::vector<int> inputs_;

  // Array of indices representing the tensors that are outputs to the
  // interpreter.
  std::vector<int> outputs_;
  
  // Read only access to list of inputs.
  std::vector<int>& inputs() { return inputs_; }

  // Read only access to list of inputs.
  const std::vector<int>& inputs() const { return inputs_; }

  // Read only access to list of outputs.
  std::vector<int>& outputs() { return outputs_; }

  // Read only access to list of outputs.
  const std::vector<int>& outputs() const { return outputs_; }
};

[링크 : https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/core/subgraph.h]

'프로그램 사용 > yolo_tensorflow' 카테고리의 다른 글

tensorflow lite yolov4  (0) 2021.06.10
tensorflow lite interpreter->AllocateTensors()  (0) 2021.05.26
imx6q neon tensorlow lite  (0) 2021.05.10
tflite type  (0) 2021.05.01
tflite example  (0) 2021.04.19
Posted by 구차니
embeded/raspberry pi2021. 5. 21. 11:43

기본 설정으로는 1080p60 / 2160p30이 한계이고

config.txt에서 hdmi_enable_4kp60=1을 넣어주면 4kp60을 지원한다고.

근데 해보고 나서 리부팅 하고 해상도 설정 바꾸어 보는데 60p가 안뜬다 -_-

(USB-C 바로 옆에 HDMI-0만 된다는데 왜 안되냐고!!)

 

The Raspberry Pi 4 can drive up to two displays, with a resolution up to 1080p at a 60Hz refresh rate. At 4K resolution, if you connect two displays then you are limited to a 30Hz refresh rate. You can also drive a single display at 4K with a 60Hz refresh rate: this requires that the display is attached to the HDMI port adjacent to the USB-C power input (labelled HDMI0). You must also enable 4Kp60 output by setting the hdmi_enable_4kp60=1 flag in config.txt. 

[링크 : https://www.raspberrypi.org/documentation/configuration/hdmi-config.md]

 

다 넣어봐도 안되네 -_ㅠ

[링크 : https://www.raspberrypi.org/forums/viewtopic.php?t=246634]

 

+ 2021.05.24

config.txt 파일 뒤져보다 보니 어라?!

pi4 항목에 은근슬쩍 들어가있는 dtoverlay=vc4-fkms-v3d

이걸 주석처리 하니 1920x1080 0Hz로 인식되어버리고 메뉴에서도 화면설정하는 항목이 사라진다 -_-

[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=vc4-fkms-v3d
max_framebuffers=2

[all]
#dtoverlay=vc4-fkms-v3d

 

raspi-config 에서는 Advanced Options - HDMI / Composite 에 해당 항목이 존재한다.

 

 

'embeded > raspberry pi' 카테고리의 다른 글

rpi cm4 어댑터 보드 or RPI zero 케이블?  (0) 2021.06.04
rpi4 cm4 csi  (0) 2021.06.03
라즈베리 파이 이미지 dd로 굽기  (0) 2021.05.21
rpi usb boot 확인?  (0) 2021.05.18
rpi 4b / tensorflow lite 빌드  (0) 2021.05.18
Posted by 구차니
embeded/raspberry pi2021. 5. 21. 10:36

맨날 윈도우에서 하다 보니 win32diskimager만 써서 몰랐는데

그냥 dd만 하면 언제 끝날지 알수가 없다 -_-

 

bs가 중요한건가.. dstat 에서 속도가 오르는게 보이네

$ dd if=2021-03-04-raspios-buster-armhf.img of=/dev/sdX bs=4M conv=fsync
$ dd if=2021-03-04-raspios-buster-armhf.img of=/dev/sdX bs=4M conv=fsync status=progress

'embeded > raspberry pi' 카테고리의 다른 글

rpi4 cm4 csi  (0) 2021.06.03
rpi 4b 해상도, 주사율  (2) 2021.05.21
rpi usb boot 확인?  (0) 2021.05.18
rpi 4b / tensorflow lite 빌드  (0) 2021.05.18
rpi 4b spec + 부팅시간  (0) 2021.05.18
Posted by 구차니