Skip to content

Commit

Permalink
Bugfix for older flutter
Browse files Browse the repository at this point in the history
  • Loading branch information
ArendJanKramer committed Jan 21, 2025
1 parent 15c3792 commit c5da942
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 38 deletions.
70 changes: 36 additions & 34 deletions lib/pages/vlm/widgets/image_grid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class _ImageGridState extends State<ImageGrid> {
padding: const EdgeInsets.only(bottom: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
spacing: 20,
children: List.generate(galleryData.length, (index) {
String path = galleryData[index];
bool isLocalFile = File(path)
Expand All @@ -97,45 +96,48 @@ class _ImageGridState extends State<ImageGrid> {
hoverStates[index] = false;
});
},
child: Stack(
children: [
AspectRatio(
aspectRatio: 1,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.black,
image: DecorationImage(
image: isLocalFile
? FileImage(File(path)) // Load local file
: NetworkImage(path) as ImageProvider,
// Load from network
fit: BoxFit.cover,
child: Padding(
padding: const EdgeInsets.only(right: 20),
child: Stack(
children: [
AspectRatio(
aspectRatio: 1,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.black,
image: DecorationImage(
image: isLocalFile
? FileImage(File(path)) // Load local file
: NetworkImage(path) as ImageProvider,
// Load from network
fit: BoxFit.cover,
),
),
),
),
),
if (isHovered)
Positioned(
top: 5,
right: 5,
child: GestureDetector(
onTap: () => removeImage(index),
child: Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.black.withAlpha(200),
shape: BoxShape.circle,
),
child: const Icon(
FluentIcons.cancel,
size: 12,
color: Colors.white,
if (isHovered)
Positioned(
top: 5,
right: 5,
child: GestureDetector(
onTap: () => removeImage(index),
child: Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.black.withAlpha(200),
shape: BoxShape.circle,
),
child: const Icon(
FluentIcons.cancel,
size: 12,
color: Colors.white,
),
),
),
),
),
],
],
),
),
);
}),
Expand Down
8 changes: 7 additions & 1 deletion openvino_bindings/src/tti/tti_inference.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ class TTIInference
// Use a lambda to initialize the 'pipe' and measure the construction time in one step
ov_pipe([&]() {
auto start_time = std::chrono::steady_clock::now();
ov::genai::Text2ImagePipeline temp_pipe(model_path, device); // Construct the pipe

ov::AnyMap enable_compile_cache;
// if (device == "GPU") {
enable_compile_cache.insert({ov::cache_dir(model_path + "/cache")});
// }

ov::genai::Text2ImagePipeline temp_pipe(model_path, device, enable_compile_cache); // Construct the pipe
auto end_time = std::chrono::steady_clock::now();

std::filesystem::path bgr_path = std::filesystem::path(model_path) / "channel_info.json";
Expand Down
5 changes: 2 additions & 3 deletions openvino_bindings/src/vlm/vlm_inference.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
#ifndef VLM_INFERENCE_H_
#define VLM_INFERENCE_H_

#include <mutex>

#include <condition_variable>
#include "src/utils/utils.h"
#include "openvino/genai/visual_language/pipeline.hpp"

Expand All @@ -30,7 +29,7 @@ class VLMInference
if (device == "GPU") {
// Cache compiled models on disk for GPU to save time on the
// next run. It's not beneficial for CPU.
enable_compile_cache.insert({ov::cache_dir("vlm_cache")});
enable_compile_cache.insert({ov::cache_dir(model_path + "/cache")});
}

ov_pipe = std::make_unique<ov::genai::VLMPipeline>(model_path, device, enable_compile_cache);
Expand Down

0 comments on commit c5da942

Please sign in to comment.