mirror of https://github.com/google/gemma.cpp.git
PaliGemma: fix image loading.
Use uint8_t to make sure values are not interpreted as signed char. PiperOrigin-RevId: 680965115
This commit is contained in:
parent
7d9fcda0d8
commit
dc2e5f1505
|
|
@ -15,6 +15,8 @@
|
|||
|
||||
#include "paligemma/image.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <cmath>
|
||||
|
|
@ -97,8 +99,8 @@ bool Image::ReadPPM(const std::string& filename) {
|
|||
height_ = height;
|
||||
int data_size = width * height * 3;
|
||||
data_.resize(data_size);
|
||||
std::vector<char> data_bytes(data_size);
|
||||
file.read(data_bytes.data(), data_size);
|
||||
std::vector<uint8_t> data_bytes(data_size);
|
||||
file.read(reinterpret_cast<char*>(data_bytes.data()), data_size);
|
||||
if (file.gcount() != data_size) {
|
||||
std::cerr << "Failed to read " << data_size << " bytes\n";
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Reference in New Issue