Skip to content

Ask Qwen Task#406

Open
annehaley wants to merge 7 commits into
masterfrom
first-hf-task
Open

Ask Qwen Task#406
annehaley wants to merge 7 commits into
masterfrom
first-hf-task

Conversation

@annehaley

Copy link
Copy Markdown
Collaborator

This PR adds a new analytics task called "Imagery: Ask Qwen". The task accepts three inputs: 1) an imagery raster, 2) a text prompt, and 3) a max_tokens value (1k - 10k). The task leverages our first Huggingface inference endpoint, sending a lower resolution version of the imagery to the endpoint along with the question and returning the response to the user.

The screenshots below show some example runs on the boston orthoimagery layer:
geodatalytics_imagery_ask_qwen_task
geodatalytics_imagery_ask_qwen_2

To support the large markdown responses, this PR makes a slight change to the Analytics Panel in the client, using vue-markdown-render for a new output type "markdown".

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 18, 2026

Copy link
Copy Markdown

Deploying geodatalytics with  Cloudflare Pages  Cloudflare Pages

Latest commit: c9ad678
Status: ✅  Deploy successful!
Preview URL: https://894360ba.geodatalytics.pages.dev
Branch Preview URL: https://first-hf-task.geodatalytics.pages.dev

View logs

Comment thread uvdat/settings/base.py Outdated
Co-authored-by: Brian Helba <brian.helba@kitware.com>
Comment thread uvdat/settings/base.py
Comment thread uvdat/core/tasks/analytics/imagery_ask_qwen.py Outdated
Comment thread uvdat/core/tasks/analytics/imagery_ask_qwen.py Outdated
Comment thread uvdat/core/tasks/analytics/imagery_ask_qwen.py Outdated
Comment thread uvdat/core/tasks/analytics/imagery_ask_qwen.py Outdated
Comment thread uvdat/core/tasks/analytics/imagery_ask_qwen.py
"role": "user",
"content": [
{"type": "image_url", "image_url": {"url": thumbnail_uri}},
{"type": "text", "text": f"{PROMPT_PREFIX} {text_prompt}"},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than prefixing the prompt, should we instead use a system message?

If we make this a general endpoint, that is where you would also have more instructions to try to avoid prompt hacking, if we care.

chat = endpoint.client.chat_completion(
model="unsloth/Qwen3.5-9B-GGUF",
messages=messages,
max_tokens=max_tokens,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be specifying a temperature?

result.write_status("Encoding imagery...")
imagery_path = utilities.field_file_to_local_path(imagery.cloud_optimized_geotiff)
src = large_image.open(imagery_path)
thumbnail_bytes, _ = src.getThumbnail(THUMBNAIL_WIDTH, encoding="PNG")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably want pass the limit to both width and height, or a long narrow image will be too large. And, I think the maximum size image will depend on the model and which projector transformers or ollama uses for it.

Comment thread pyproject.toml
"pyvips==3.1.1.8.18.1",
"uvdat-flood-sim[large-image-writer]==1.0.4",
"xdg-base-dirs==6.0.2",
"huggingface-hub>=1.14.0",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"huggingface-hub>=1.14.0",
"huggingface-hub==1.14.0",

Renovate will try to pin this, so you might as well do it now. I'm not saying this is generally a best practice for Python, but it's how Renovate works currently.

from .analysis_type import AnalysisInputError, AnalysisTask, AnalysisType

ENDPOINT_NAMESPACE = "Kitware"
ENDPOINT_NAME = "qwen3-5-9b-gguf-ulh"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I previously suggested that we didn't have to keep this a secret, now that I see it hardcoded here, I'm worried that future open source users or developers will try to use our deployment-specific endpoint (I've seen this happen before).

I think we should make this a deployment-specific env var.

To avoid proliferation of multiple env vars, we could potentially pack this into a single URL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants