-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Using AI-PP3 against a local model of llama3.1:8b (provider = openai-compatible), the produced PP3 file has capitalized names for parameters such as Surround=AVERAGE and Surrsrc=AVERAGE.
This causes rawtherapee (either GUI or CLI) to crash. Having built rawtherapee in debug mode, the issue is that in improcfun.cc ImProcFunctions::ciecam_02float, it does checks like if (params->colorappearance.surrsrc == "Average") which fails the parameter values that our AI-PP3 produces.
The initialization of various floats to correct values (c = 0.f originally) therefore doesn't happen, and subsequent function calls which expect sensible values (Ciecam02::initcam1float) now outputs a wh = 0 value, so then the final calls to generate the computation value coefQ = 32767.f / wh means coefQ is 0, and finally the call Qpro = CAMBrightCurveQ[(float)(Qpro * coefQ)] / coefQ; means you are getting a divide by zero, and the entire program segfaults.
Ideally the construction of params in rawtherapee would do a simple "to lower case" and then do comparisons on lowercase values - I am not sure if this is something that could be recommended for the rawtherapee team? How would I do this? Do you think it is worth raising an issue with them?
Alternatively, we need to sanitize the AI output to be sensible to match what RawTherapee is expecting. The verbose AI-PP3 AI is attached.
verbose-AI.txt
Here is the processed output from AI-PP3 which shows the invalid values for color appearance and other sections:
AI response received and processed
Found 6 direct section changes
Applying changes to section [Exposure]
Changed: Auto=false -> Auto=false
Changed: Clip=0.02 -> Clip=0.02
Changed: Compensation=0 -> Compensation=-1
Changed: Brightness=0 -> Brightness=25
Changed: Contrast=0 -> Contrast=10
Changed: Saturation=0 -> Saturation=5
Changed: Black=0 -> Black=20
Changed: HighlightCompr=0 -> HighlightCompr=50
Changed: HighlightComprThreshold=0 -> HighlightComprThreshold=100
Changed: ShadowCompr=50 -> ShadowCompr=30
Changed: HistogramMatching=false -> HistogramMatching=true
Changed: CurveFromHistogramMatching=false -> CurveFromHistogramMatching=true
Changed: ClampOOG=true -> ClampOOG=false
Changed: CurveMode=Standard -> CurveMode=Standard
Changed: CurveMode2=Standard -> CurveMode2=Standard
Changed: Curve=0; -> Curve=0.1;0.3;0.6;0.8;1;
Changed: Curve2=0; -> Curve2=0.1;0.4;0.7;0.9;1;
Applying changes to section [Local Contrast]
Changed: Enabled=false -> Enabled=true
Changed: Radius=80 -> Radius=80
Changed: Amount=0.20000000000000001 -> Amount=0.3
Changed: Darkness=1 -> Darkness=1.2
Changed: Lightness=1 -> Lightness=1.5
Applying changes to section [Sharpening]
Changed: Enabled=false -> Enabled=true
Changed: Contrast=20 -> Contrast=15
Changed: Method=usm -> Method=usm
Changed: Radius=0.5 -> Radius=0.7
Changed: BlurRadius=0.20000000000000001 -> BlurRadius=0.3
Changed: Amount=200 -> Amount=150
Changed: Threshold=20;80;2000;1200; -> Threshold=20;80;2000;1200;
Changed: OnlyEdges=false -> OnlyEdges=false
Changed: EdgedetectionRadius=1.8999999999999999 -> EdgedetectionRadius=1.8
Changed: EdgeTolerance=1800 -> EdgeTolerance=1800
Changed: HalocontrolEnabled=false -> HalocontrolEnabled=true
Changed: HalocontrolAmount=85 -> HalocontrolAmount=90
Changed: DeconvRadius=0.75 -> DeconvRadius=0.9
Changed: DeconvAmount=100 -> DeconvAmount=120
Changed: DeconvDamping=0 -> DeconvDamping=0
Changed: DeconvIterations=30 -> DeconvIterations=30
Applying changes to section [White Balance]
Changed: Enabled=true -> Enabled=true
Changed: Setting=Camera -> Setting=Camera
Changed: Temperature=6504 -> Temperature=6504
Changed: Green=1 -> Green=1.2
Changed: Equal=1 -> Equal=1.1
Changed: TemperatureBias=0 -> TemperatureBias=-10
Changed: StandardObserver=TWO_DEGREES -> StandardObserver=TWO_DEGREES
Changed: Itcwb_green=0 -> Itcwb_green=0
Changed: Itcwb_rangegreen=1 -> Itcwb_rangegreen=1
Changed: Itcwb_nopurple=false -> Itcwb_nopurple=false
Changed: Itcwb_alg=false -> Itcwb_alg=false
Changed: Itcwb_prim=beta -> Itcwb_prim=beta
Changed: Itcwb_sampling=false -> Itcwb_sampling=false
Changed: CompatibilityVersion=2 -> CompatibilityVersion=2
Applying changes to section [Color appearance]
Changed: Enabled=false -> Enabled=true
Changed: Degree=90 -> Degree=110
Changed: AutoDegree=true -> AutoDegree=true
Changed: Degreeout=90 -> Degreeout=110
Changed: AutoDegreeout=true -> AutoDegreeout=true
Changed: Surround=Average -> Surround=AVERAGE
Changed: complex=normal -> complex=NORMAL
Changed: ModelCat=16 -> ModelCat=16
Changed: CatCat=clas -> CatCat=CLAS
Changed: Surrsrc=Average -> Surrsrc=AVERAGE
Changed: AdaptLum=16 -> AdaptLum=16
Changed: Badpixsl=0 -> Badpixsl=0
Changed: Model=RawT -> Model=RAW_T
Changed: Illum=i50 -> Illum=i50
Changed: Algorithm=No -> Algorithm=NO
Changed: J-Light=0 -> J-Light=10
Changed: Q-Bright=0 -> Q-Bright=20
Changed: C-Chroma=0 -> C-Chroma=30
Changed: S-Chroma=0 -> S-Chroma=40
Changed: M-Chroma=0 -> M-Chroma=50
Changed: J-Contrast=0 -> J-Contrast=60
Changed: Q-Contrast=0 -> Q-Contrast=70
Changed: H-Hue=0 -> H-Hue=80
Changed: RSTProtection=0 -> RSTProtection=0
Changed: AdaptScene=2000 -> AdaptScene=2000
Changed: AutoAdapscen=true -> AutoAdapscen=true
Changed: YbScene=18 -> YbScene=18
Changed: Autoybscen=true -> Autoybscen=true
Changed: SurrSource=false -> SurrSource=false
Changed: Gamut=true -> Gamut=true
Changed: Tempout=5003 -> Tempout=5003
Changed: Autotempout=true -> Autotempout=true
Changed: Greenout=1 -> Greenout=1.2
Changed: Tempsc=5003 -> Tempsc=5003
Changed: Greensc=1 -> Greensc=1.1
Changed: Ybout=18 -> Ybout=18
Changed: Datacie=false -> Datacie=false
Changed: Tonecie=false -> Tonecie=false
Changed: CurveMode=Lightness -> CurveMode=LIGHTNESS
Changed: CurveMode2=Brightness -> CurveMode2=BRIGHTNESS
Changed: CurveMode3=Chroma -> CurveMode3=CHROMA
Changed: Curve=0; -> Curve=0.1;0.3;0.6;0.8;1;
Changed: Curve2=0; -> Curve2=0.1;0.4;0.7;0.9;1;
Changed: Curve3=0; -> Curve3=0.1;0.5;0.8;1;1;
Applying changes to section [Dehaze]
Changed: Enabled=false -> Enabled=true
Changed: Strength=50 -> Strength=75
Changed: ShowDepthMap=false -> ShowDepthMap=false
Changed: Depth=25 -> Depth=30
Changed: Saturation=50 -> Saturation=60
Preview file cleaned up
My PP3 is attached. It can be ran against any NEF or RW2 and it'll crash. I ran it with:
rawtherapee-cli -Y -o /ssd2/PP3s/NIK_0324.pp3 -j100 -js3 -b16 -p /ssd2/PP3s/NIK_0324.pp3 -c /ssd2/Processing/NIK_0324.NEF
NIK_0324.pp3.txt
My prompt is as follows (very similar to the one in the documentation):
Unleash the full potential of RAW image pp3 settings with a dramatic flair. Elevate your creative precision by providing:
1. ANALYSIS: A profound exploration into the image's essence, identifying its strengths and areas for transformation.
2. PLAN: Set ambitious goals for adjustments and articulate a vivid creative vision that transcends ordinary imagery.
3. CHANGES: Deliver precise SEARCH/REPLACE blocks to breathe life into the envisioned transformation.
RULES:
- Respect the original structure & headers as the foundation upon which to build your masterpiece.
- Proceed thoughtfully, modifying only those values necessary to achieve the desired dramatic effect.
- Maintain the document's integrity by never adding or removing sections.
- Style goals: Portraits: natural skin tones, soft contrast, gentle sharpening, pleasant background separation.
- Scenery: vibrant yet realistic colors, balanced highlights/shadows, enhanced architectural textures.
- Wildlife: rich fur/feather detail, balanced warmth, moderate noise reduction.
- General: preserve dynamic range, avoid blown highlights, tasteful microcontrast.
- Increase midtone contrast slightly for images that appear dull, while preserving shadow detail.
- The document should be suitable for a high-quality coffee-table book: slightly saturated, smooth tonal transitions, fine detail without harshness.
- Ensure consistent look across mixed lighting situations.
CHANGES FORMAT:
\`\`\`
<<<<<<< SEARCH
[Exposure]
Auto=false
Clip=0.02
Compensation=0
Brightness=0
=======
[Exposure]
Auto=false
Clip=0.02
Compensation=-0.5
Brightness=25
>>>>>>> REPLACE
\`\`\`
Prepare to embark on this transformative journey as the pp3 content to be optimized follows below: