You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Module definition structure
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
"esim_cpu", // Module name
NULL, // Module documentation, may be NULL
-1, // Size of per-interpreter state of the module,
// or -1 if the module keeps state in global variables.
methods // Method definitions
};
// Function to initialize the module (PyInit_esim_cpu)
extern "C" PyObject* PyInit_esim_cpu() {
// Module initialization code
// Example:
PyObject* module = PyModule_Create(&moduledef);
if (module == nullptr) {
return nullptr;
}
// Add other module-specific initialization code here
return module;
}
// Remove actual implementations from here
// Only keep declarations
std::vectortorch::Tensor esim_forward_cpu_impl(
const torch::Tensor& images,
const torch::Tensor& timestamps,
const torch::Tensor& init_reference_values,
torch::Tensor& reference_values_over_time,
const torch::Tensor& offsets,
torch::Tensor& events,
torch::Tensor& timestamps_last_event,
float contrast_threshold_negative,
float contrast_threshold_positive,
int64_t refractory_period);
// Leave out the existing implementations of esim_forward_cpu and esim_forward_count_events_cpu
// These should only be declared in esim_cpu_kernel.h
esimc_cpu_kernel.h:
#pragma once
#include <torch/extension.h>
#include
I've managed to build esim_torch:
pip install esim_torch/
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Processing d:\aaa\rpg_vid2e-master\esim_torch
Preparing metadata (setup.py) ... done
Building wheels for collected packages: esim_cpu
Building wheel for esim_cpu (setup.py) ... done
Created wheel for esim_cpu: filename=esim_cpu-0.0.0-cp39-cp39-win_amd64.whl size=37949 sha256=1458cf7c13b64221c2c96c5572ed2d2af1b0aa48781d4be0ed60dcee4e0dd9f9
Stored in directory: C:\Users\23863\AppData\Local\Temp\pip-ephem-wheel-cache-97dmsggn\wheels\a4\97\22\f0cfbc8a8dfd697f39129bd49557b5b4a6da7da9915eba601f
Successfully built esim_cpu
Installing collected packages: esim_cpu
Attempting uninstall: esim_cpu
Found existing installation: esim_cpu 0.0.0
Uninstalling esim_cpu-0.0.0:
Successfully uninstalled esim_cpu-0.0.0
Successfully installed esim_cpu-0.0.0
However, when you run the code, you will get an error:
python scripts/generate_events.py --input_dir=example/upsampled --output_dir=example/events --contrast_threshold_neg=0.2 --contrast_t
hreshold_pos=0.2 --refractory_period_ns=0
Traceback (most recent call last):
File "D:\aaa\rpg_vid2e-master\esim_torch\scripts\generate_events.py", line 4, in
from esim_torch import esim_torch
ModuleNotFoundError: No module named 'esim_torch'
The text was updated successfully, but these errors were encountered:
esim_cpu.cpp:
#include "esim_cpu_kernel.h"
#include <torch/extension.h>
#include
#include
#include
#include <Python.h>
// Module method definitions
static PyMethodDef methods[] = {
{NULL, NULL, 0, NULL} // Sentinel
};
// Module definition structure
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
"esim_cpu", // Module name
NULL, // Module documentation, may be NULL
-1, // Size of per-interpreter state of the module,
// or -1 if the module keeps state in global variables.
methods // Method definitions
};
// Function to initialize the module (PyInit_esim_cpu)
extern "C" PyObject* PyInit_esim_cpu() {
// Module initialization code
// Example:
PyObject* module = PyModule_Create(&moduledef);
if (module == nullptr) {
return nullptr;
}
}
// Remove actual implementations from here
// Only keep declarations
std::vectortorch::Tensor esim_forward_cpu_impl(
const torch::Tensor& images,
const torch::Tensor& timestamps,
const torch::Tensor& init_reference_values,
torch::Tensor& reference_values_over_time,
const torch::Tensor& offsets,
torch::Tensor& events,
torch::Tensor& timestamps_last_event,
float contrast_threshold_negative,
float contrast_threshold_positive,
int64_t refractory_period);
std::vectortorch::Tensor esim_forward_count_events_cpu_impl(
const torch::Tensor& images,
torch::Tensor& reference_values_over_time,
torch::Tensor& event_counts,
float contrast_threshold_negative,
float contrast_threshold_positive);
// Existing implementations
std::vectortorch::Tensor esim_forward_cpu(
const torch::Tensor& images,
const torch::Tensor& timestamps,
const torch::Tensor& init_reference_values,
torch::Tensor& reference_values_over_time,
const torch::Tensor& offsets,
torch::Tensor& events,
torch::Tensor& timestamps_last_event,
float contrast_threshold_negative,
float contrast_threshold_positive,
int64_t refractory_period) {
// Existing implementation
}
std::vectortorch::Tensor esim_forward_count_events_cpu(
const torch::Tensor& images,
torch::Tensor& reference_values_over_time,
torch::Tensor& event_counts,
float contrast_threshold_negative,
float contrast_threshold_positive) {
// Existing implementation
}
esim_cpu_kernel.cpp:
#include "esim_cpu_kernel.h"
#include <torch/extension.h>
#include
#include
#include
// Placeholder implementations for the missing functions
std::vectortorch::Tensor esim_forward_cpu_impl(
const torch::Tensor& images,
const torch::Tensor& timestamps,
const torch::Tensor& init_reference_values,
torch::Tensor& reference_values_over_time,
const torch::Tensor& offsets,
torch::Tensor& events,
torch::Tensor& timestamps_last_event,
float contrast_threshold_negative,
float contrast_threshold_positive,
int64_t refractory_period) {
// Placeholder implementation
std::cout << "Running esim_forward_cpu_impl" << std::endl;
return {reference_values_over_time, events};
}
std::vectortorch::Tensor esim_forward_count_events_cpu_impl(
const torch::Tensor& images,
torch::Tensor& reference_values_over_time,
torch::Tensor& event_counts,
float contrast_threshold_negative,
float contrast_threshold_positive) {
// Placeholder implementation
std::cout << "Running esim_forward_count_events_cpu_impl" << std::endl;
return {reference_values_over_time, event_counts};
}
// Leave out the existing implementations of esim_forward_cpu and esim_forward_count_events_cpu
// These should only be declared in esim_cpu_kernel.h
esimc_cpu_kernel.h:
#pragma once
#include <torch/extension.h>
#include
// 声明函数
std::vectortorch::Tensor esim_forward_cpu(
const torch::Tensor& images,
const torch::Tensor& timestamps,
const torch::Tensor& init_reference_values,
torch::Tensor& reference_values_over_time,
const torch::Tensor& offsets,
torch::Tensor& events,
torch::Tensor& timestamps_last_event,
float contrast_threshold_negative,
float contrast_threshold_positive,
int64_t refractory_period);
std::vectortorch::Tensor esim_forward_count_events_cpu(
const torch::Tensor& images,
torch::Tensor& reference_values_over_time,
torch::Tensor& event_counts,
float contrast_threshold_negative,
float contrast_threshold_positive);
// 声明占位符函数
std::vectortorch::Tensor esim_forward_cpu_impl(
const torch::Tensor& images,
const torch::Tensor& timestamps,
const torch::Tensor& init_reference_values,
torch::Tensor& reference_values_over_time,
const torch::Tensor& offsets,
torch::Tensor& events,
torch::Tensor& timestamps_last_event,
float contrast_threshold_negative,
float contrast_threshold_positive,
int64_t refractory_period);
std::vectortorch::Tensor esim_forward_count_events_cpu_impl(
const torch::Tensor& images,
torch::Tensor& reference_values_over_time,
torch::Tensor& event_counts,
float contrast_threshold_negative,
float contrast_threshold_positive);
I've managed to build esim_torch:
pip install esim_torch/
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Processing d:\aaa\rpg_vid2e-master\esim_torch
Preparing metadata (setup.py) ... done
Building wheels for collected packages: esim_cpu
Building wheel for esim_cpu (setup.py) ... done
Created wheel for esim_cpu: filename=esim_cpu-0.0.0-cp39-cp39-win_amd64.whl size=37949 sha256=1458cf7c13b64221c2c96c5572ed2d2af1b0aa48781d4be0ed60dcee4e0dd9f9
Stored in directory: C:\Users\23863\AppData\Local\Temp\pip-ephem-wheel-cache-97dmsggn\wheels\a4\97\22\f0cfbc8a8dfd697f39129bd49557b5b4a6da7da9915eba601f
Successfully built esim_cpu
Installing collected packages: esim_cpu
Attempting uninstall: esim_cpu
Found existing installation: esim_cpu 0.0.0
Uninstalling esim_cpu-0.0.0:
Successfully uninstalled esim_cpu-0.0.0
Successfully installed esim_cpu-0.0.0
However, when you run the code, you will get an error:
python scripts/generate_events.py --input_dir=example/upsampled --output_dir=example/events --contrast_threshold_neg=0.2 --contrast_t
hreshold_pos=0.2 --refractory_period_ns=0
Traceback (most recent call last):
File "D:\aaa\rpg_vid2e-master\esim_torch\scripts\generate_events.py", line 4, in
from esim_torch import esim_torch
ModuleNotFoundError: No module named 'esim_torch'
The text was updated successfully, but these errors were encountered: